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

add compression of content streams #60

Open
mtcxgarble opened this issue Jun 20, 2017 · 2 comments
Open

add compression of content streams #60

mtcxgarble opened this issue Jun 20, 2017 · 2 comments

Comments

@mtcxgarble
Copy link
Contributor

Kind of a feature request :)

Added compression to all content streams (not very fluent in go, changes have been based on PdfDictionaryObj.build; "works for me")

Should never create an invalid PDF (/FlateDecode Filter will be applied before interpreting content). Size of compressed content stream could be bigger than uncompressed stream for very small streams, or for streams with high-entropy content. But compression will work in most cases.

Text-rich documents should profit most, as PDF Unicode-Encoding (hex-encoded UCS16) is rather verbose and should compressed comparatively well.

Maybe this should be made into an document-level option, so that compression can be turned off if needed?

Pull Request: #59

Thank you!

@mtcxgarble
Copy link
Contributor Author

Re: #61

compressLevel can be set with .SetCompressLevel(level int) after .init() has completed (sets level to zlib.DefaultCompression).

Possible levels like in "compress/zlib", .SetCompressLevel(0) will create PDF with uncompressed streams, same as .SetNoCompression() (comfort method...)

Usage:

pdf := gopdf.GoPdf{}
pdf.Start(...) // compressLevel is now zlib.DefaultCompression
pdf.SetCompressLevel(0) // or pdf.SetNoCompression() => uncompressed

@vantaboard
Copy link
Contributor

@oneplus1000 can you close this issue if it has been resolved?

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