You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Falko Riemenschneider (JIRA)" <ji...@apache.org> on 2018/09/03 06:41:00 UTC
[jira] [Created] (PDFBOX-4308) PDDocument protect changes color
palette
Falko Riemenschneider created PDFBOX-4308:
---------------------------------------------
Summary: 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
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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org