Pdf with watermarks is displayed incorrectly on the gmail viewer

1. I created pdf file with watermark (any text) on your demo (http://www.aspose.com/demos/.net-components/aspose.pdf/csharp/PdfDemos/Stamps/AddTextStamp.aspx).

2. Take this file and sent it to @gmail.com as attachment.

3. Open this attachment in https://mail.google.com/.

Problem: Watermark is displayed incorrectly on the gmail viewer.

I added watermarks via another program - watermarks are displayed correctly.

I attached pdf and screenshot from gmail viewer - please see and investigate my problem.

This issue is very important for our clients.



Hi Pavel,


Thanks for your inquiry. While testing the scenario with Aspose.Pdf for .NET 8.7, I am afraid I am unable to reproduce the reported issue. Please find enclosed source PDF document and gmail viewer screenshot. Please download and try latest version of Aspose.Pdf, hopefully it will resolve the issue.

Please feel free to contact us for any further assistance.

Best Regards,

I tried with latest version Aspose.Pdf for .NET 8.7 in my program, but the problem is still reproduced.

What is the version Aspose.Pdf used on the demo sample?

Can you please let me know in which Windows and browser version are you testing my issue in?

I attached a small screen cast.


Thank you!

Hi Pavel,

Thanks for sharing the details.

I have tested the scenario while using the online example Add Text Stamp and I am able to reproduce the same problem that when viewing the file in Gmail viewer, the watermark is not properly being displayed. Please note that the online examples are currently using an old release v6.2 and these examples will be removed shortly.

However, when I have tested the scenario using Aspose.Pdf for .NET 8.7.0, the TextStamp is properly appearing in the resultant file. For your reference, I have also attached the sample PDF generated with the latest release. We are sorry for this inconvenience.

//open document
Document pdfDocument = new Document("c:/pdftest/Font_Text_Issue.pdf");

foreach (Page pdfPage in pdfDocument.Pages)
{
    //create text stamp
    TextStamp textStamp = new TextStamp("Hello World...");

//set whether stamp is background
    textStamp.Background = true;

//set origin
    textStamp.XIndent = Convert.ToDouble(10);
    textStamp.YIndent = Convert.ToDouble(10);

//set text properties
    textStamp.TextState.Font = FontRepository.FindFont("Arial");
    textStamp.TextState.FontSize = 14.0F;
    textStamp.TextState.FontStyle = FontStyles.Bold;
    textStamp.TextState.FontStyle = FontStyles.Italic;
    textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.Aqua;

//add stamp to particular page
    pdfPage.AddStamp(textStamp);
}

pdfDocument.Save("c:/pdftest/WatermarkTest.pdf");

Thank you for your quick response.

I use PdfFileStamp and FormattedText

I found a problem, I have some questions.

Code [C#]:

FormattedText ft = new FormattedText(
"Hello World!",
Color.Red,
"C:\\Windows\\Fonts\\Arial.ttf",
EncodingType.Identity_h,
false,
10);

PdfFileStamp fileStamp = new PdfFileStamp();
fileStamp.BindPdf(@"C:\pdftest\Test.pdf");
Stamp stamp = new Stamp {Opacity = 0.8f, IsBackground = true};
stamp.SetOrigin(100, 100);
stamp.BindLogo(ft);
fileStamp.AddStamp(stamp);
fileStamp.Save(@"C:\pdftest\Test1.pdf");

fileStamp.Close();

When FormattedText has parameter 'bool embedded'=false - issue is reproduced, when true - is properly appearing in gmail viewer.

What does it mean this parameter 'embedded' in FormattedText constructor?



Hi Pavel,


Thanks for sharing the details.

I have tested the scenario and I am able to
notice the same problem that Watermark is not properly being displayed in gmail viewer when using PdfFileStamp class. For the sake of correction, I have logged this problem
as PDFNEWNET-36169 in our issue tracking system. We will further
look into the details of this problem and will keep you updated on the status
of correction. Please be patient and spare us little time. We are sorry for
this inconvenience.

Hi Pavel,

In addition to Nayyer reply. As a workaround you can use new DOM approach for adding text stamp. Hopefully it will help you to accomplish your requirements. However, we will keep you updated about the original issue resolution progress via this forum thread.

//open document
Document pdfDocument = new Document(myDir+"Pdf_headerfooter.pdf");
FormattedText ft = new FormattedText("Hello World!", System.Drawing.Color.Red,
"C:\\Windows\\Fonts\\Arial.ttf", EncodingType.Identity_h, false, 10);

foreach (Page pdfPage in pdfDocument.Pages)
{
    //create text stamp
    TextStamp textStamp = new TextStamp(ft);
    //set whether stamp is background
    textStamp.Background = true;
    //set origin
    textStamp.XIndent = Convert.ToDouble(10);
    textStamp.YIndent = Convert.ToDouble(10);
    //set text properties
    // textStamp.TextState.Font = FontRepository.FindFont("Arial");
    // textStamp.TextState.FontSize = 14.0F;
// textStamp.TextState.FontStyle = FontStyles.Bold;
// textStamp.TextState.FontStyle = FontStyles.Italic;
// textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.Aqua;
    //add stamp to particular page
    pdfPage.AddStamp(textStamp);
}
pdfDocument.Save(myDir+"WatermarkTest.pdf");

We are sorry for the inconvenience caused.

Best Regards,

Hi, Thank you.

What does it mean parameter 'embedded' in FormattedText constructor?

Hi Pavel,


When setting True as value for embedded parameter, the font will be embedded inside resultant PDF document.