-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
compressed PDF not displayd correctly in OSX preview #2904
Comments
Duplicate of #2743. If you already have experience PDF compression. Could you maybe prepare a pull request with the fix? That would be awesome! |
Well... i can try. Probably gona take a while until i understand the structure of this project and find everything i need to change. |
Thanks. If you need a pointer let me know ;) |
@HackbrettXXX Can you make a quick overview on how the current Deflater.js is used? I keep finding pits and pieces all around the place, and it makes it rather difficult to root it out and supstitute it :D. |
Of course:
The deflater is also used in the png_support ( The deflater accepts uncompressed Uint8Arrays and returns compressed Uint8Arrays. I'm not sure if the bug is inside Deflater.js or in the |
@HackbrettXXX Did some testing. I commented out adler and deflater and used pako and different combinations. It seems deflater + adler dont work together. |
@HackbrettXXX Could you instruct me on how to build the package in such a way that it would work, if i have done |
Sorry for the delayed response. If you're importing pako from node_modules, you probably need to add the |
So i did npm install pako. Next i created a file under libs called pako.js with content
Now im importing it by
In rollup do i just input the libs file and output the rolledUp file and in between i use resolve and commonjs ? |
Just change the
|
Ok build does not give errors. Any good way to test if the built version works?
|
Well, create some PDFs with compression on and see if they open fine in the OSX PDF preview. You should probably also test PDFs with some binary data such as images or fonts. |
Seems to work fine. But new issue, but harder one. I have a link in the PDF. Visually looks fine, but when clicked on in OSX preveiw # gets replaced with %23. Any ideas? |
"%23" is "#" URI encoded, so this is correct. If you open the link in a browser it should work. Or is the issue that the # that separates URI fragments is encoded, as well? Then it's probably an issue of |
Nevermind # to %23 is a macOS issue. Anyways... i think im done... how do i push it up or something? I cant push as i get acces denied :D. |
You need to fork the repo, then create a pull request. |
Should be ok. But this is my first fork ever :D so please check if i did everything correctly :D |
a workaround (for garbled text when using compression) I have found is using when creating a new jsPDF instance
|
Fixed in #2944. |
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
`
`
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
The text was updated successfully, but these errors were encountered: