question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

compressed PDF not displayd correctly in OSX preview

See original GitHub issue

Using the jsPDF to construct a PDF file and for reduced size it is compressed. Works fine in most places but when opened in OSX preview, the text is all jumbled up.

When validating the PDF with: https://www.pdf-online.com/osa/validate.aspx i get `

Compliance pdf1.4
Result Document does not conform to PDF/A.
Details Validating file “cert(2).pdf” for conformance level pdf1.4Error in Flate stream: data error.The document does not conform to the requested standard.The document doesn’t conform to the PDF reference (missing required entries, wrong value types, etc.).The document does not conform to the PDF 1.4 standard.Done.

`

I used //@ts-ignore doc.__private__.setPdfVersion("1.4"); in hopes of maybe resolving the issue. But it seems its not the issue with PDF version but with the compression algorithm. Is there a workaround for this issue?

I have worked with mozillas PDF.js libary and there i also had to implement compression. We needed to modify/extend the PDF.js libary to accomodate our signing logic. There i used pako libary to deflate a data stream. Maybe look into what pako has done? https://github.com/nodeca/pako

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
wesleymostiencommented, Nov 3, 2020

a workaround (for garbled text when using compression) I have found is using filters: ['ASCIIHexEncode', 'FlateEncode']

when creating a new jsPDF instance

new jsPDF({
	compress: true,
	filters: ['ASCIIHexEncode', 'FlateEncode'],
	format: [widthPdf, heightPdf],
	putOnlyUsedFonts: true,
	unit: 'px',
})
0reactions
HackbrettXXXcommented, Dec 7, 2020

Fixed in #2944.

Read more comments on GitHub >

github_iconTop Results From Across the Web

If PDFs or images aren't the correct size in Preview on Mac
In the Preview app on your Mac, choose Preview > Settings. · To choose how to display documents, click PDF or Images, then...
Read more >
Quick Fixes to Preview Not Working on Mac (2022)
Just import the PDF you are having an issue with and apply your desired changes and save it as a new PDF. Then...
Read more >
Why are some PDFs scrambled when opened with Preview on ...
If your issue is that text doesn't show when using the quick look preview of a pdf (the one that shows documents by...
Read more >
How to change image and PDF display sizes in Preview
Have you ever opened an image or a PDF in Preview on your Mac and it looked odd? It may have appeared to...
Read more >
Preview app displays line weights and texts incorrectly in the ...
If the Preview app in the Mac OS is not displaying PDF correctly, try opening it with a different program like Adobe reader,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found