Skip to content

Commit

Permalink
🔨 compress content stream
Browse files Browse the repository at this point in the history
  • Loading branch information
hwding committed Feb 12, 2019
1 parent 8ea7c89 commit 10c6311
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/com/amastigote/unstamper/core/Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.sun.istack.internal.NotNull;
import org.apache.pdfbox.contentstream.operator.Operator;
import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSString;
import org.apache.pdfbox.pdfparser.PDFStreamParser;
import org.apache.pdfbox.pdfwriter.ContentStreamWriter;
Expand Down Expand Up @@ -127,8 +128,9 @@ public static void process(

/* >> write modified tokens back to the stream */
PDStream newContents = new PDStream(pdDocument);
OutputStream out = newContents.createOutputStream();
OutputStream out = newContents.createOutputStream(COSName.FLATE_DECODE);
ContentStreamWriter writer = new ContentStreamWriter(out);

writer.writeTokens(objects);
out.close();
/* << write modified tokens back to the stream */
Expand Down

3 comments on commit 10c6311

@hwding
Copy link
Owner Author

@hwding hwding commented on 10c6311 Feb 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#5

@DonaldTsang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this change some of the content-defined-chunk hashes?
static_chunking
dynamic_chunking1

@hwding
Copy link
Owner Author

@hwding hwding commented on 10c6311 Feb 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DonaldTsang Any kind of editing leads to hash change, compress only fixes the issue which compressed content was no longer compressed after removing the watermark.

In some circumstances, the edited file slightly inflates and in others, slightly deflates, it might affect some chunkes.

Please sign in to comment.