diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.38k stars 1.13k forks source link

PDF generated file can't open by Adobe Acrobat or other PDF readers except Chrome #2625

Closed pacomart closed 3 months ago

pacomart commented 4 months ago

Describe the bug The generated PDF file cannot be opened in Adobe Acrobat Reader or others pdf readers, displaying an error 110. This error occurs when inserting an image with src={Buffer}.

To Reproduce Render a react-pdf with an

<Image style={styles.image} src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."/>

and try to open with Adobe Acrobat Reader.

Expected behavior Open the PDF file in other applications

Desktop (please complete the following information):

Thank

pwnedev commented 4 months ago

Same problem here. The introduction of this bug was pretty recent.

I rolledback to: "@react-pdf/pdfkit": "3.1.2", "@react-pdf/renderer": "3.3.4", "@react-pdf/textkit": "4.3.0",

and I don't have any errors anymore.

Using "pdfkit" v3.1.3 or "renderer" v3.3.5 re-introduces the bug, so I left it as 3.1.2 and 3.3.4. Also "textkit" v4.3.0 is needed because newer versions seem to break in "renderer" v3.3.4.

pacomart commented 4 months ago

I tried to rollback to "@react-pdf/renderer": "3.3.4", 3.3.3 and 3.3.2 and fail too.

pwnedev commented 4 months ago

I tried to rollback to "@react-pdf/renderer": "3.3.4", 3.3.3 and 3.3.2 and fail too.

You can use renderer v3.3.4 if you also install versions v3.1.2 of pdfkit and v4.3.0 of textkit. It's necessary to manually install those child dependencies because otherwise it will install the most up-to-date version of those child dependencies and that won't work.

They problem was either introduced in pdfkit v3.1.3 or one of it's child dependencies

max-got commented 4 months ago

Temporary solution, till it is fixed: Add the following to your package.json

"overrides": {
        "@react-pdf/renderer": {
            "@react-pdf/pdfkit": "3.1.2"
        }
    }

then npm i and the images are working as expected

marcjansen89 commented 4 months ago

Using the following versions still results in generated .pdf file (Images that have a base64 src) not being able to open in Adobe Acrobat. Chrome, Edge, FireFox opens without problems. Inspecting the file in Affinity Designer shows the inserted Images as grey squares.

"@react-pdf/pdfkit": "3.1.2", "@react-pdf/renderer": "3.3.4", "@react-pdf/textkit": "4.3.0",

ooga commented 4 months ago

@diegomura I found the error and opened a PR. It's very small please merge it quickly

mathfranca commented 4 months ago

I'm having the same problem using "@react-pdf/renderer": "3.1.9", still no solution for me. Updating the dependency to a newer version breaks stuff and is not possible for me at the moment

dreamvishnu commented 4 months ago

I was using Yarn "resolutions": { "**/@react-pdf/pdfkit": "3.0.2" }

it work for me able to work for png & jpg images

lightbulbzez commented 3 months ago

Same problem here. The introduction of this bug was pretty recent.

I rolledback to: "@react-pdf/pdfkit": "3.1.2", "@react-pdf/renderer": "3.3.4", "@react-pdf/textkit": "4.3.0",

and I don't have any errors anymore.

Using "pdfkit" v3.1.3 or "renderer" v3.3.5 re-introduces the bug, so I left it as 3.1.2 and 3.3.4. Also "textkit" v4.3.0 is needed because newer versions seem to break in "renderer" v3.3.4.

Rollback worked for me too, hopefully this will be solved in the future