addTextStamp error

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

@panosk

Thanks for contacting support.

We were able to replicate the issue using following code snippet and Aspose.PDF for .NET 19.3. We have logged it as PDFNET-46226 in our issue tracking system for the sake of correction. As soon as we have definite updates regarding issue resolution, we will share with you. Please be patient and spare us little time.

Document pdfDocument = new Document(dataDir + "123.pdf");
string str = "This is test stamp.";
Facades.FormattedText text = new Facades.FormattedText(str);
text.AddNewLineText(DateTime.Now.ToString());
TextStamp textStamp = new TextStamp(str);
textStamp.TextState.Font = FontRepository.FindFont("Arial");
string strSize = "50";
textStamp.TextState.FontSize = Convert.ToSingle(strSize);
textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue);
textStamp.Opacity = 0.5;
textStamp.VerticalAlignment = VerticalAlignment.Center;
textStamp.HorizontalAlignment = HorizontalAlignment.Center;
pdfDocument.Pages[1].AddStamp(textStamp);
pdfDocument.Save(dataDir + "123_out.pdf");

We are sorry for the inconvenience.

Hello,

do you have any updates regarding this issue?

Thank you!

@panosk

We regret to share that earlier logged issue is not yet resolved. Please note that it was logged under free support model and it has low priority. We will surely investigate and resolve it on first come first serve basis. We will inform you as soon as we have some certain news about its resolution. Please spare us some time.

We are sorry for the inconvenience.