[ 
https://issues.apache.org/jira/browse/PDFBOX-4308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16602300#comment-16602300
 ] 

Tilman Hausherr commented on PDFBOX-4308:
-----------------------------------------

That was a nasty one… until I noticed that the object number in the PDF wasn't 
the same than the one in {{COSWriter.visitFromString}}.

Todo next: I'll create a test based on your file.

There will be a snapshot available within the next few hours at
https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/2.0.12-SNAPSHOT/

> PDDocument protect changes color palette
> ----------------------------------------
>
>                 Key: PDFBOX-4308
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4308
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.11
>            Reporter: Falko Riemenschneider
>            Priority: Major
>             Fix For: 2.0.12, 3.0.0 PDFBox
>
>         Attachments: Quelldatei.pdf, Zieldatei-mit-Schutz.pdf
>
>
> When applying protection to a PDF the resulting PDF shows weird background 
> colors.
> The following minimal sample program produces the observed behaviour in 
> attached PDF "Zieldatei-mit-Schutz.pdf"
> {code:java}
> package protecttest;
> // $ java -version
> // openjdk version "1.8.0_181"
> // OpenJDK Runtime Environment (build 
> 1.8.0_181-8u181-b13-0ubuntu0.18.04.1-b13)
> // OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
> // compile with
> // javac -cp pdfbox-2.0.11.jar protecttest/PdfProtector.java
> // execute with
> // java -cp pdfbox-2.0.11.jar:commons-logging-1.1.3.jar:. 
> protecttest.PdfProtector
> import java.io.File;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
> import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
> public class PdfProtector {
>     public static void main(String[] args) throws Exception {
>     // load and save with no protection
>     PDDocument d1 = PDDocument.load(new File("Quelldatei.pdf"));
>     d1.save(new File("Zieldatei-ohne-Schutz.pdf"));
>     d1.close();
>     // everything seems fine with the resulting PDF
>     // load and save with protection
>         PDDocument d2 = PDDocument.load(new File("Quelldatei.pdf"));
>     AccessPermission ap = new AccessPermission();
>     ap.setCanAssembleDocument(false);
>     ap.setCanModify(false);
>     d2.protect(new StandardProtectionPolicy("foobar","",ap));
>     d2.save(new File("Zieldatei-mit-Schutz.pdf"));
>     d2.close();
>     // resulting file is rendered with odd colors
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to