Muthukumar R created PDFBOX-3876:
------------------------------------

             Summary: Setting “overprint=true” for a specific ColorSpace on PDF 
(not the entire PDF Page)
                 Key: PDFBOX-3876
                 URL: https://issues.apache.org/jira/browse/PDFBOX-3876
             Project: PDFBox
          Issue Type: Bug
            Reporter: Muthukumar R


I have a requirement to set overprint=true at ColorSpace level on a "PDF" (not 
for the entire PDF Page). I'm trying to solve this using PDFBox.

Again, I want to apply overprint only for a specific colorSpace (see If 
condition in the sample code below), but 
graphicsState.setStrokingOverprintControl(true); seems to be setting overprint 
for the entire PDF Page (all colorSpaces).

Here's the sample code. Anyone came across this problem? Am I missing something?

Sample code:


{code:java}
public static void fixPdfOverprint(String inputFilePath, String outputFilePath) 
throws IOException {
        final ByteArrayInputStream pdfStream = new 
ByteArrayInputStream(readFileIntoMemory(inputFilePath));
        try(PDDocument document = PDDocument.load(pdfStream)) {
            for (PDPage page : document.getDocumentCatalog().getPages()) {
                try(PDPageContentStream contentStream = 
createPageContentStream(document, page)) {
                    PDExtendedGraphicsState graphicsState = new 
PDExtendedGraphicsState();
                    PDResources pdResources = 
document.getDocumentCatalog().getPages().get(0).getResources();
                    for (COSName cosName : pdResources.getColorSpaceNames()) {
                         if(cosName.getName().equals("<my specific 
colorSpace>")) {
                           graphicsState.setStrokingOverprintControl(true); // 
Why this is setting for the entire page rathen than just this colorSpace. Btw - 
I confirmed that this if condition is correct.
                         }
                    }
                    contentStream.setGraphicsStateParameters(graphicsState);
                }
            }

            document.save(outputFilePath);
        }
    }


{code}




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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

Reply via email to