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

White boxes after adding color in background

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Bug
    • 2.0.21
    • None
    • Utilities

    Description

      Hey,

      I'm facing a problem when adding a background color to some documents with pdfbox. I am using the following code to add color do a document:

       

      try (PDPageContentStream cs = new PDPageContentStream(doc, page, PDPageContentStream.AppendMode.PREPEND, true, true)) { 
      cs.saveGraphicsState();
      cs.setGraphicsStateParameters(gs);                                                                       cs.setNonStrokingColor(hexToColor(hexColor));
      cs.addRect(0, 0, page.getMediaBox().getWidth(), page.getMediaBox().getHeight()); cs.fill(); 
      cs.restoreGraphicsState(); 
      }
      

      I've tried adding color in 3 different ways and always get the same problem (see attached documents). I don't know how to fix this and would really appreciate it if someone could help me out or steer me in the right direction. Thank you in advance

       

       

      Best regards,

      Wilhelm

      Attachments

        1. without BG color-darkened.PDF
          237 kB
          Michael Klink
        2. without BG color.PDF
          191 kB
          Wilhelm Ziegler
        3. with BG color.PDF
          223 kB
          Wilhelm Ziegler

        Activity

          People

            Unassigned Unassigned
            wizi89 Wilhelm Ziegler
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: