Created
August 13, 2014 20:03
-
-
Save ashelley/6cbad3f489499996a95e to your computer and use it in GitHub Desktop.
pdfkit compression performance workaround for this problem https://github.com/joyent/node/issues/6623#issuecomment-52064608
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/reference.coffee b/lib/reference.coffee | |
index 9e961d6..b98a868 100644 | |
--- a/lib/reference.coffee | |
+++ b/lib/reference.coffee | |
@@ -12,6 +12,7 @@ class PDFReference | |
@compress = @document.compress and not @data.Filter | |
@uncompressedLength = 0 | |
@chunks = [] | |
+ @chunksToCompress = []; | |
initDeflate: -> | |
@data.Filter = 'FlateDecode' | |
@@ -32,7 +33,7 @@ class PDFReference | |
if @compress | |
@initDeflate() if not @deflate | |
- @deflate.write chunk | |
+ @chunksToCompress.push(chunk); | |
else | |
@chunks.push chunk | |
@data.Length += chunk.length | |
@@ -42,6 +43,7 @@ class PDFReference | |
@write chunk | |
if @deflate | |
+ @deflate.write(Buffer.concat(@chunksToCompress)); | |
@deflate.end() | |
else | |
@finalize() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment