Excel to PDF conversion and adding watermark- watermark display junk characters

Hi,

We are creating a workbook using Aspose Cells and converting it into PDF. while conversion we are adding watermark to PDF pages.

Most of the times the output is fine, but sometimes watermark is showing dots …

Find below the code used for this,

//////////////////////
CELLS.Workbook oTempWorkbook = new CELLS.Workbook();
oTempWorkbook.Value.FileFormat = CELLS.FileFormatType.Excel97To2003;


…populate worksheets with data


MemoryStream oTempMemoryStream = new MemoryStream();
oWorkbook.Value.Save(oTempMemoryStream, CELLS.SaveFormat.Pdf);

#region Apply Security [Allow Print & Copy Only]
MemoryStream oTempSecurityMemoryStream = new MemoryStream();

PDF.Facades.PdfFileSecurity oPdfFileSecurity = new PDF.Facades.PdfFileSecurity();
oPdfFileSecurity.InputStream = oTempMemoryStream;
oPdfFileSecurity.OutputStream = oTempSecurityMemoryStream;

PDF.Facades.DocumentPrivilege oDocumentPrivilege = PDF.Facades.DocumentPrivilege.AllowAll;
oDocumentPrivilege.AllowModifyContents = false;
oDocumentPrivilege.AllowModifyAnnotations = false;
oDocumentPrivilege.AllowFillIn = false;
oDocumentPrivilege.AllowCopy = false;

oDocumentPrivilege.ChangeAllowLevel = 0;
oPdfFileSecurity.SetPrivilege(oDocumentPrivilege);

oTempMemoryStream = oTempSecurityMemoryStream;
#endregion

//open document
PDF.Document oDocument = new PDF.Document(oTempMemoryStream);

#region Create and Format Watermark
PDF.TextStamp oTextStamp = new PDF.TextStamp(“Custom Watermark”);

oTextStamp.Background = true;
oTextStamp.XIndent = 0;
oTextStamp.YIndent = 0;

oTextStamp.VerticalAlignment = PDF.VerticalAlignment.Center;
oTextStamp.HorizontalAlignment = PDF.HorizontalAlignment.Center;

oTextStamp.RotateAngle = 45;

oTextStamp.TextState.Font = PDF.Text.FontRepository.FindFont(“Arial”);
oTextStamp.TextState.FontSize = 34.0F;
oTextStamp.TextState.FontStyle = PDF.Text.FontStyles.Bold;
oTextStamp.TextState.ForegroundColor = System.Drawing.Color.LightGray;



#region Apply Watermark to Specific Pages
for (int i = 1; i <= oDocument.Pages.Count; i++)
{
oDocument.Pages[i].AddStamp(oTextStamp);
}
#endregion

oDocument.Save(oTempMemoryStream);

//////////////////////

Let me know is there anything wrong in the code, how to fix this issue.

Thanks

Hi,

Some additional information,

Test Scenario (same output pdf file):
1. Adobe Acrobat Reader X and Adobe Acrobat Reader XI reports font issue and watermark appears as dots
2. Open the PDF in Sumatra PDF, opens correctly
3. Open the PDF in CutePDF, opens correctly
4. Open the PDF in Windows 8.1 Reader App, opens correctly

But most the users are using Adobe X or XI.

Thanks

Hi Andrew,


Thank you for contacting Aspose support.

By looking at your provided code snippet, we believe you are using two Aspose APIs to achieve your ultimate goal. You are using Aspose.Cells API to dynamically load the data in a spreadsheet, and to convert it to the PDF format. Then you are loading the resultant PDF (generated with Aspose.Cells API) with Aspose.Pdf API for further processing including the watermarking operation. At the moment we are not sure which API is contributing most to the presented problem, however if you share your input spreadsheet along with your complete source code, we would be in a better position to guide you further in this regard. We would request you to please provide the sample spreadsheet and a sample console application to replicate the issue on our end. Moreover, please provide the environment details as listed below.

  • Operating System version
  • Operating System Architecture (32bit/64bit)
  • Target Framework
  • Aspose.Cells & Aspose.Pdf versions

Please note, we are going to move this thread the Aspose.Total support forum so that the other teams could also have a look into your presented scenario.