Hello,
I’m using Aspose.Pdf to add text stamps to pdf. The code seems to work fine but i can’t open in some cases the new pdf files with Acrobat Reader DC.
I recieve the following messages:
-> “An error exists on this page. Acrobat may not display the page correctly. Please cotnact the person who created the PDF document to correct the problem”
-> "Coannot find of create the font ‘RKNJFU+Tahoma’. Some characters may not display or print correctly. ".
The final document is diplayed with dots where the text stamp should have been. I can see the final document with other pdf readers, browsers etc, correctly, but i’d like to know if i can fix the problem i’m experiencing with acrobat reader.
I’m sending you the original doc and the doc after i added the text stamp:
123.pdf (216.2 KB)
123 (1).pdf (239.2 KB)
and the code sample:
public int AsposePdfAddTextStamp(string inputFile, string outputFile, string text1, string text2, int topMargin1, int topMargin2, string fontName, int fontSize, int horizontalAlignment, int leftMargin, int rightMargin, int wherePage, ref string errorMessage)
{
try
{
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputFile);if (text1.Length > 0) { TextStamp textStamp = Utils.createTextStamp(text1); textStamp.Background = false; textStamp.TopMargin = topMargin1; if (leftMargin > 0) textStamp.LeftMargin = leftMargin; if (rightMargin > 0) textStamp.RightMargin = rightMargin; if (horizontalAlignment == 0) textStamp.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right; else if (horizontalAlignment == 1) textStamp.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center; else if (horizontalAlignment == 2) textStamp.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Left; textStamp.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Top; textStamp.Rotate = Aspose.Pdf.Rotation.None; textStamp.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont(fontName); textStamp.TextState.FontSize = fontSize; //textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue); if (wherePage == 0) pdfDocument.Pages[1].AddStamp(textStamp); // 1 είναι η πρώτη σελίδα else if (wherePage == 1) pdfDocument.Pages[pdfDocument.Pages.Count].AddStamp(textStamp); // τελευταία σελίδα else if (wherePage == 2) { pdfDocument.Pages[1].AddStamp(textStamp); // πρώτη σελίδα pdfDocument.Pages[pdfDocument.Pages.Count].AddStamp(textStamp); // τελευταία σελίδα } } if (text2.Length > 0) { TextStamp textStamp2 = Utils.createTextStamp(text2); textStamp2.Background = false; textStamp2.TopMargin = topMargin2; if (leftMargin > 0) textStamp2.LeftMargin = leftMargin; if (rightMargin > 0) textStamp2.RightMargin = rightMargin; if (horizontalAlignment == 0) textStamp2.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right; else if (horizontalAlignment == 1) textStamp2.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center; else if (horizontalAlignment == 2) textStamp2.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Left; textStamp2.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Top; textStamp2.Rotate = Aspose.Pdf.Rotation.None; textStamp2.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont(fontName); textStamp2.TextState.FontSize = fontSize; //textStamp2.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue); if (wherePage == 0) pdfDocument.Pages[1].AddStamp(textStamp2); // 1 είναι η πρώτη σελίδα else if (wherePage == 1) pdfDocument.Pages[pdfDocument.Pages.Count].AddStamp(textStamp2); // τελευταία σελίδα else if (wherePage == 2) { pdfDocument.Pages[1].AddStamp(textStamp2); // πρώτη σελίδα pdfDocument.Pages[pdfDocument.Pages.Count].AddStamp(textStamp2); // τελευταία σελίδα } } //save output document pdfDocument.Save(outputFile); } catch (Exception exc) { errorMessage = exc.Message; return -1; } return 0; }
Thank you