Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Generating PDFs with many images fails. #5281

Open
tycho-kirchner opened this issue Dec 6, 2022 · 0 comments
Open

Generating PDFs with many images fails. #5281

tycho-kirchner opened this issue Dec 6, 2022 · 0 comments

Comments

@tycho-kirchner
Copy link

wkhtmltopdf version(s) affected: 0.12.6

OS information
Debian Bullseye

Description
Generating large PDF's with many images currently fails with, .e.g.
Warning: Failed to load file:///path/to/img.jpg (ignore), if the number of open files is exceeded. The "fix" is calling, e.g.
ulimit -n 9999 to increase that limit. However, intuitively I suppose having open all files in parallel is not a strict necessity but rather an artifact of the current implementation which may be worth fixing. See also related issues here and here

How to reproduce
Set a low file limit ulimit -n 20 and try to convert a html page with 21 existing images:

<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta charset="UTF-8">
    <style></style>
    </head>
    <body>
    <img style="width: 20mm; height=20mm;" src="img/foo1.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo2.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo3.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo4.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo5.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo6.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo7.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo8.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo9.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo10.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo11.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo12.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo13.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo14.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo15.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo16.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo17.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo18.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo19.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo20.png"/>
    <img style="width: 20mm; height=20mm;" src="img/foo21.png"/>
</body>
</html>

On my machine this produces the following commandline output:

$ wkhtmltopdf  --allow img/  example.html example.pdf
Loading pages (1/6)
Warning: Failed to load file:///home/tycho/tasiomaetc/Axel/img/foo11.png (ignore)
Warning: Failed to load file:///home/tycho/tasiomaetc/Axel/img/foo12.png (ignore)
Warning: Failed to load file:///home/tycho/tasiomaetc/Axel/img/foo13.png (ignore)
Warning: Failed to load file:///home/tycho/tasiomaetc/Axel/img/foo14.png (ignore)
Warning: Failed to load file:///home/tycho/tasiomaetc/Axel/img/foo15.png (ignore)
Warning: Failed to load file:///home/tycho/tasiomaetc/Axel/img/foo16.png (ignore)
Warning: Failed to load file:///home/tycho/tasiomaetc/Axel/img/foo17.png (ignore)
Warning: Failed to load file:///home/tycho/tasiomaetc/Axel/img/foo18.png (ignore)
Warning: Failed to load file:///home/tycho/tasiomaetc/Axel/img/foo19.png (ignore)
Warning: Failed to load file:///home/tycho/tasiomaetc/Axel/img/foo21.png (ignore)
Counting pages (2/6)                                               
Resolving links (4/6)                                                       
Loading headers and footers (5/6)                                           
Printing pages (6/6)
Done                                                                      

Expected behavior
Each file is only needed once so running into the open file limit is not expected (and not clear from the error message).

Possible Solution
Maybe open only all images on the current PDF page? You'll make it 😅. Thanks for the nice converter so far!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant