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

Tilman Hausherr commented on PDFBOX-3876:
-----------------------------------------

Setting overprint is not related to a colorspace. You have to set the extGState 
in the content stream for the parts where you want it to apply, i.e. at the 
moment when you set the colorspace. (Having it in the resources is not "setting 
it")
See
https://stackoverflow.com/questions/38433534/pdfbox-inconsistent-co-ordinate-system-how-do-i-draw-a-rectangle
and
https://stackoverflow.com/questions/40267719/pdfbox-2-1-0-when-printed-from-ie11-transparent-text-watermark-has-opaque-ba
for examples where people call setGraphicsStateParameters(). Your current code 
just creates empty pages unless createPageContentStream does more than just 
calling the same constructor.

Closing as this isn't a bug but a "how to" question, which belong on the 
mailing list or on stackoverflow (where you asked the same, I'll answer there 
later this weekend if nobody else does)
https://pdfbox.apache.org/support.html


> 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