react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

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

Open pacomart opened this issue 4 months ago • 7 comments

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):

  • OS: Windows
  • Browser chrome
  • Pdf reader Adobe Acrobar v2023.008.20470
  • React-pdf version v3.3.7

Thank

pacomart avatar Feb 07 '24 20:02 pacomart

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.

pwnedev avatar Feb 08 '24 13:02 pwnedev

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

pacomart avatar Feb 10 '24 10:02 pacomart

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

pwnedev avatar Feb 10 '24 13:02 pwnedev

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

max-got avatar Feb 10 '24 14:02 max-got

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",

marcjansen89 avatar Feb 13 '24 11:02 marcjansen89

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

ooga avatar Feb 18 '24 06:02 ooga

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

mathfranca avatar Feb 21 '24 19:02 mathfranca

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

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

dreamvishnu avatar Feb 29 '24 15:02 dreamvishnu

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

lightbulbzez avatar Mar 22 '24 10:03 lightbulbzez