We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Multiple Watermark text using 1 TextStamp setDraw(true) doesnt work

Hi, I successfully created some text and changed its alpha to make it look like a watermark using TextStamp.
Thing is, i have 2 sets of text using FormattedText

e,g,

FormattedText ft = new FormattedText(“sample 1 line”, java.awt.Color.LIGHT_GRAY,
FontStyle.Helvetica, EncodingType.Winansi, false, 15, 30);

   ft.addNewLineText("sample 2 line", 30);
   ft.addNewLineText("sample 3 line", 30);            
    
    TextStamp stamp = new TextStamp(ft);

This works ok , 3 lines are drawn. the problem is if i call stamp.setDraw(true). only 1 line of text is drawn and not all 3.

@chitgoks

The setDraw(boolean value) specifies if text stamp would be drawn as graphics or text. Please use it as setDraw(false) in order to add stamp as text. Furthermore, you may also set opacity of TextStamp to make it transparent using TextStamp.setOpacity() method. Please let us know if you have another inquiry.

hi asad.ali

i have no problems adding stamp as text. 3 lines of text are displayed. issue is that i do not want them to be selectable.

so i call setDraw(true) to draw them. problem is, only 1 line is drawn and not all 3 lines of text. plus i noticed that the small letter y , is cut off. For example, try to use the text Copyright 3 times by calling addNewLineText() and setting alignment to CENTER and rotation to VERTICAL.

Look at the two images. the 2nd is drawn but only one line of text is drawn and even the letter y is cut off.

selectable.png (129.8 KB)
drawn.png (111.2 KB)

@chitgoks

Thank you for elaborating it further.

Would you please share SSCCE code along with generated PDF document so that we may investigate the scenario further and assist you accordingly. Before sharing requested data, please ensure using Aspose.PDF for Java 19.5 in your environment.

        FormattedText ft = new FormattedText("Test Line 1", java.awt.Color.LIGHT_GRAY, 
        FontStyle.Helvetica, EncodingType.Winansi, false, 80, 50);
        ft.addNewLineText("Test Line Company Here", 50);
        ft.addNewLineText("Test Line 3 Merry", 50);

    TextStamp stamp = new TextStamp(ft);
    stamp.setBackground(true);
    stamp.setOpacity(0.5);
    stamp.setTextAlignment(VerticalAlignment.Center);
    stamp.setHorizontalAlignment(HorizontalAlignment.Center);
    stamp.setVerticalAlignment(VerticalAlignment.Center);
    stamp.setRotateAngle(-90);

    pdfDocument.getPages().get_Item(1).addStamp(stamp);

So just use this code to see result, then call stamp.setDraw(true) next.

@chitgoks

We have been able to reproduce the issue in our environment. A ticket with ID PDFJAVA-38598 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

ok. i hope when setdraw is true the drawn text should also look like when it is set to false.

the text has borders drawn which is ugly.

@chitgoks

We have recorded your concerns and will certainly consider these while addressing the issue.

Is there any news about this problem. I am facing exactly this same issue. I am using TextStamp to ass watermark to my pdf file, but it is not visible (text is selectable but not visible!). Then I changed setBacground(false), then I see text but I can select it. I do not want to select it. Then I use setDraw(true), and watermark looks very ugly. Is there any fix for that. I just want to have a watermark in the background that is not selectable. I have tried with TextStamp and with WatermarkArtifact and still nothing, simply does not work as expected.

cheers,
Pawel

@paweluz

The earlier logged ticket is currently under the phase of investigation. As soon as it is completely analyzed, we will be able to share some updates regarding its resolution. Furthermore, can you please share your sample PDF along with sample code snippet so that we can add it to the ticket. We will surely include your case in the investigation and fix it.

Hi, it has been 2 years and this bug has not been fixed… that does not sound promising at all. I have already started separate topic for my issue in here: Add watermark/stamp to the PDF file - not visible but selectable. @mudassir.fayyaz has already created ticket for that and it is PDFJAVA-40734. But to be honest I am bit sceptical since this one: PDFJAVA-38598 has not been fixed yet, it would be very surprising if my new one be fixed sooner. Anyway thanks for your support.

@paweluz

We humbly apologize for the inconvenience caused by this issue. The ticket linked with this thread is under the phase of investigation at the moment. We have recorded your concerns and will surely take care of them during issue investigation. We will inform you in this forum thread as soon as we make some definite progress towards its resolution.

We again apologize for the inconvenience faced.