You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (Jira)" <ji...@apache.org> on 2021/02/12 15:59:00 UTC

[jira] [Commented] (PDFBOX-5101) White boxes after adding color in background

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

Tilman Hausherr commented on PDFBOX-5101:
-----------------------------------------

The white boxes are in the PDF, here's an excerpt of the content stream:
{code}
  1 g
  104.9 85.224 454.51 12.6 re
  f*
(...)
  104.9 72.504 454.51 12.72 re
  f*
(...)
  104.9 59.904 454.51 12.6 re
  f*
(...)
  104.9 47.184 454.51 12.72 re
  f*
{code}
"1 g" is white. The rest is a rectangle and fill it.

What you could do is to edit the content stream and to replace "1 g" with the commands you used, which are
{code}
/gs4 gs
/DeviceRGB cs
0.95686 0.8 0.8 sc
{code}
or just "0.95686 0.8 0.8 rg".

See the RemoveAllText.java example to see how to access and modify the page content stream.


> White boxes after adding color in background
> --------------------------------------------
>
>                 Key: PDFBOX-5101
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5101
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 2.0.21
>            Reporter: Wilhelm Ziegler
>            Priority: Major
>              Labels: how-to
>         Attachments: with BG color.PDF, without BG color.PDF
>
>
> 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:
>  
> {code:java}
> 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(); 
> }
> {code}
> 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



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org