Adding New Text to PDF page is not working properly

Hi

I have used the below code to add the new text(slide 12 of 52) to the existing PDF page and tried to save the each page as single page pdf file.

Attached sample Output. The text is printed in reverse order. Kindly help to resolve this issue.

//Open document

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("Input.pdf");

Aspose.Pdf.Document newDocument;

TextBuilder textBuilder;

int pageCount=1;

//Create text fragment

TextFragment textFragment = new TextFragment();

textFragment.Position = new Position(100, 600);

//Set text properties

textFragment.TextState.FontSize = 12;

textFragment.TextState.Font = FontRepository.FindFont("TimesNewRoman");

//textFragment.TextState.BackgroundColor = Color.LightGray;

textFragment.TextState.ForegroundColor = System.Drawing.Color.Black;

foreach (Aspose.Pdf.Page pdfPage in pdfDocument.Pages)

{

textFragment.Text = string.Concat("Slide ", SN.ToString(), " of ", sc.Tostring());

//Save new document

newDocument = new Aspose.Pdf.Document();

//Create TextBuilder object

textBuilder = new TextBuilder(pdfPage);

//Append the text fragment to the PDF page

textBuilder.AppendText(textFragment);

newDocument.Pages.Add(pdfPage);

newDocument.Save(string.Concat(outpath,sn,Tostring(), pageCount, "pdf"));

pageCount++;

}

Hi Ponraj,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 7.8.0 and as per my observations, when viewing the resultant PDF file, the text is not properly appearing. I am unable to replicate the issue related to reverse text string. In fact I am getting “Cannot Find or create the font ‘QCRSQD+TimesNewRoman’. Some characters may not display or print correctly” error message when viewing the PDF file and also the string is not properly appearing . For the sake of correction, I have logged this issue as PDFNEWNET-35131 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.