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

MH commented on PDFBOX-1176:
----------------------------

Well, it would be at least a big step forward if adding a watermark text would 
work. I tried with PDPageContentStream.drawString() to get at least some kind 
of workaround. (The examples I have found to add an Image via 
PDFContent.addImage() is no option for us.) But the first problem is, that this 
text overlaps the content and the text is always in black - even though I set 
cs.setStrokeingColor(Color.RED). My code:

---------------------------------------------------------------
final PDPageContentStream cs = new PDPageContentStream(doc, page, true, false, 
true); //4th parameter = resetContext
try {

    //simple text above the page:
    cs.beginText();
    cs.setStrokingColor(fontColor); //doesn't work
    cs.setFont(font, fontSize);
    cs.moveTo(10, 10);
    //cs.moveTextPositionByAmount(10, 10);
    //cs.setTextTranslation((pageSize.getWidth() / 2.0) - (stringWidth / 2.0), 
(pageSize.getHeight() / 2.0) - (fontSize / 2.0));
    cs.setTextRotation((double) 0.2, (pageSize.getWidth() / 2.0) - (stringWidth 
/ 2.0), (pageSize.getHeight() / 2.0) - (fontSize / 2.0));
    //cs.setTextScaling(10.0, 10.0, (pageSize.getWidth() / 2.0) - (stringWidth 
/ 2.0), (pageSize.getHeight() / 2.0) - (fontSize / 2.0));
    cs.setStrokingColor(Color.BLUE); //doesn't work
    cs.drawString(text);
    cs.endText();
} finally {
    if (cs != null) {
        cs.close();
    }
}
-------------------------------------
                
> Watermark
> ---------
>
>                 Key: PDFBOX-1176
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1176
>             Project: PDFBox
>          Issue Type: Wish
>            Reporter: Rubesh MX
>              Labels: Watermark
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> I am checking if watermarks can  be added to a PDF doc and the same way can 
> be removed, so far I could not find any option to do that with PDFBox; It 
> will be better if we have an option to add and remove watermak to a PDF.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to