Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-3876

Setting “overprint=true” for a specific ColorSpace on PDF (not the entire PDF Page)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • None

    Description

      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:

      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);
              }
          }
      
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            rajumuthukumar Muthukumar R
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: