I am using react-pdf version 3 and pdf viewer shows pdf correctlly in my ui but when i download that pdf it does not render in adobe acrobat and microsoft edge while it renders correctly in google chrome and Google drive pdf viewer. What coul be the issue that some applicatiomn can render that and some can’t also what could be the solution to use in react-pdf.
2
Answers
I can reproduce the issue with react-pdf official sample: https://react-pdf.org/repl. After I download the PDF file, it failed to open with Adobe Acrobat.
For Edge browser, are you using the new PDF reader powered by Adobe Acrobat? If so, it can’t show the PDF file correctly. You can check if you have enabled this feature by opening this page edge://policy/ in Edge, you’ll find this policy NewPDFReaderEnabled is set to true.
If you disable or don’t configure this policy, Edge will use its own PDF reader and the PDF file can be opened correctly.
Edit: What KJ says is exactly true. For the official demo, the issue lies on the first image. Change that image and the download file works in Adobe Acrobat.
There appears to be a flaw in the "Reactor" (React-PDF in a server). The "standard" example as first highlighted by @YuZhou exhibits a similar failing, as per the question.
The Problem is the first image in the page is stored incorrectly thus does not meet Adobe reqirements for the page to be displaid.
Its such a tiny yet very significant (potential overflow) bug, that some PDF Readers may work around it or ignore it yet other systems scream "Virus".
My first attempt to accept the download was blocked by Windows Defender as a Viral PDF and not to be run. However I have downloaded that file before.
My Second attempt download succeeded as it had now been scanned and found benign. However the 1st page (Page [0]) could not be rendered as per the "Question". This applies to Acrobat "Standalone" viewers, and the one used in MS Edge.
Yet other viewers seem to simply just not show the cover page image. So that is where we look.
Test 1 is simply change the image ref from 1 to 2 . Sure enough the download is "Safe and Secure and Working" flawlessly.
So what is the oddity (around that first image) and we see it is a coloured (black and white) image, so as a JPG it must be seen on screen as 24bit RGB.
Looking inside the faulty PDF we see the colour is correctly stated as screen
/ColorSpace /DeviceRGB
so that is not a problem and same for the other coded instructions, EXCEPT the variable for/BitsPerComponent undefined
. Clearly wrong.So the problem is the potential for bitwise overflow during rendering as the 24bit image is not correctly defined as 24/3 = 8 thus should be
/BitsPerComponent 8
As soon as we overwrite "undefined" with "8" the result is perfectly safe and no potential for buffer overflow, thus instantly viewable in Acrobat and Edge.