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

Free Support Forum - aspose.com

Text Stamp is not Visible in PDF

Hi,
I am using TestStamp on PDF documents. Few documents, I don’t see text stamp. However, if I copy the TextStamp area in PDF document and paste into notepad, I can see the text.

I have check the PDF document property and noticed there was no fonts in that documents. Again, I tried with embedded front. Now I can see the fonts in PDF document property, but still I don’t see TextStamp in PDF document.

Aspose.Pdf 10.3.0.0
Language C#
.NET Framework 4.5.2/ 4.6.2
IDE Visual Studio 2017

@srasiah22,
Kindly send us the complete details of the use case, including input PDF document, code snippet and also let us know which Aspose.Pdf API version you are using. We will investigate and share our findings with you.

Best Regards,
Imran Rafique

Hi Imran Rafique

I don’t see an option to upload the PDF.
I am using Aspose.Pdf 10.3.0.0.

Use case
We have to stamp a PDF document with image and text. First we apply image stamp on PDF document then applying text over that. Only few PDF documents I cant see text stamp (not visible). However, I can see the text when I copy text stamp area and paste it in to notepad.

Code snippet

public void AddText(Page pdfPage, StampPDFWithTextLines stamp, StampTextLine stampTextLine)
{
try
{

            TextStamp textStamp = new TextStamp(stampTextLine.Text)
            {

                Background = true,
                XIndent = stampTextLine.XIndent,
                YIndent = stampTextLine.YIndent
            };

            
            textStamp.TextState.FontStyle = MapFontStyle(stampTextLine.FontStyle);
            textStamp.TextState.Font = MapFont(stampTextLine.Font);
            textStamp.TextState.Font.IsEmbedded = true;
            textStamp.TextState.FontSize = (float)stampTextLine.FontSize;
            textStamp.TextState.ForegroundColor = MapFontColor(stampTextLine.FontColor);
           
            textStamp.TextState.HorizontalAlignment = MapHorizontalAlignment(stampTextLine.TextHorizontalAlignment);

            textStamp.WordWrap = stampTextLine.WordWrap;
            textStamp.Scale = false;
            textStamp.Width = stampTextLine.Width;
            textStamp.HorizontalAlignment = MapHorizontalAlignment(stamp.StampHorizontalAlignment);              

            pdfPage.AddStamp(textStamp);
           }
        catch (Exception)
        {

            throw;
        }

    }

I got this fixed by setting Background = false. However, i don’t know how this works.

@srasiah22,
It is nice to hear from you that the problem has been resolved. The Background indicates whether the content is stamped as background or not. If the value is true, the stamp content is laid at the bottom. By default, the value is false, the stamp content is laid at the top.

Best Regards,
Imran Rafique

@imran.rafique

Thank you for the information.