algoo / preview-generator

generates previews of files with cache management
https://pypi.org/project/preview-generator/
MIT License
228 stars 50 forks source link

HTML->PDF adds extra empty page and cuts off some lines #204

Open nikkicantrell opened 3 years ago

nikkicantrell commented 3 years ago

Generating a PDF preview for an HTML document has a couple problems:

raphj commented 3 years ago

Hi @nikkicantrell. Thanks for your report.

Do you happen to have examples for the three cases that you could provide us so we can investigate further?

If so, would you mind if we use these samples in our test suit to avoid future regression?

raphj commented 3 years ago

It would also be great if you could send us a minimal working code that reproduces these issues.

schmirob000 commented 3 years ago

Giving this snippet of HTML in file file_name to PreviewManager.get_pdf_preview() generates a 2-page pdf without NAME anywhere in the file. That's first line cut and empty page at the beginning


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>look it up yourself</title>
</head>
<body>
    NAME<br>
    look it up yourself<br><br>

    LINK<br>
    <a href="https://www.google.com">https://www.google.com</a><br>

    DESCRIPTION<br>
    test file<br>
</body>
schmirob000 commented 3 years ago

With the above html in the same directory as the below python script as simple.html, running this generates the failed pdf.


from preview_generator.manager import PreviewManager

PREVIEW_OUTPUT_FOLDER = '.'

def main():

    proof_file = 'simple.html'

    preview_manager = PreviewManager(PREVIEW_OUTPUT_FOLDER, create_folder=False)
    preview_manager.get_pdf_preview(proof_file)

if __name__ == '__main__':
    main()