Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent base64 return values #113

Closed
michaelschneiderdaimler opened this issue Mar 11, 2020 · 2 comments
Closed

Inconsistent base64 return values #113

michaelschneiderdaimler opened this issue Mar 11, 2020 · 2 comments

Comments

@michaelschneiderdaimler
Copy link

michaelschneiderdaimler commented Mar 11, 2020

Hi,

we're using your plugin in an iOS app.
We observed that if pass the same input to the plugin several times, we get different result base64 strings. The generated PDF looks consistent, but we are wondering what the cause for this behaviour could be.
We want to generate some critical packaging labels, so we need to be sure that the plugin behaves somewhat consistently - any idea what is going on? I didn't find anything by digging through the code...
Input:
pdf.fromData('<style type="text/css">.clara {color: blue; font-weight: lighter; font-family: Arial, Helvetica}</style><html><div class="clara">Hello from Stuttgart!</div><div>Hallo aus Deutschland ... </div></html>', { documentSize: 'A4', type: 'base64'}).then(function(res) { console.log(res) })

Result:
pdf-result-1.txt
pdf-result-2.txt

@cesarvr
Copy link
Owner

cesarvr commented Mar 15, 2020

Hey @michaelschneiderdaimler ,

It's going to be difficult to achieve accuracy at byte level between the same PDF, because the PDF API (used by the browser behind the scenes) adds arbitrary metadata values (like dates, prefixes, etc) in the PDF script code that internally defines the final document. If you transform this base64 into a PDF script you will find that objects in the PDF script are not even (sometimes) defined in the same order, which explains the difference in Base64 results.

On the other hand the visual accuracy will be there because that's the purpose of PDF technology.

Example:

Block of text defined internally in different order with arbitrary prefixes:

Screenshot 2020-03-15 at 13 24 31

Visual representation of the files:

Screenshot 2020-03-15 at 13 26 59

Screenshot 2020-03-15 at 13 27 16

Hope it helps.

@michaelschneiderdaimler
Copy link
Author

michaelschneiderdaimler commented Mar 16, 2020

Hi Cesar,
many thanks for the explanation!
We were already suspecting that some dynamic stuff was inserted in the PDF, but since I found no such code neither in the plugin nor in the native code, I was wondering where that happened.

I'm closing the issue.

Best regards
michael

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

No branches or pull requests

2 participants