Free Support Forum - aspose.com

mender.AddText does not work

I am trying to add text to pdf file using Aspose.Pdf.Facades.PdfFileMend.

this is a code:

//add number of pages to the fax doc
Aspose.Pdf.Facades.PdfFileMend mender = new Aspose.Pdf.Facades.PdfFileMend(inStream, outStream);


//create formatted text
Aspose.Pdf.Facades.FormattedText text = new Aspose.Pdf.Facades.FormattedText("Total number of Pages: " + PageCount.ToString(),
System.Drawing.Color.White,
System.Drawing.Color.Black,
Aspose.Pdf.Facades.FontStyle.Courier,
Aspose.Pdf.Facades.EncodingType.Winansi,
true,
14
);
mender.AddText(text, 1, 1, 780);
mender.Close();

inStream.Close();
outStream.Close();
I can build the file , but text is not visible on background and when sent to printer I am getting error about bad pdf format.


Hi Serge,

Thanks for using our products.

I have tested the scenario using Aspose.Pdf for .NET 6.3.0 while using one of my sample PDF documents and I am unable to notice any problem. The text is properly being added to the PDF document. I have used the following code snippet to test the scenario. Can you please confirm which version of product you are using ?

If possible, can you please share the source PDF document so that we can test the scenario at our end. We apologize for your inconvenience.

[C]


// get information of source PDF document
Aspose.Pdf.Facades.PdfFileInfo pinfo = new PdfFileInfo(“d:/pdftest/Source-Mend.pdf”);
try
{
//add number of pages to the fax doc
Aspose.Pdf.Facades.PdfFileMend mender = new Aspose.Pdf.Facades.PdfFileMend(“d:/pdftest/Source-Mend.pdf”, “d:/pdftest/TextMend-updated.pdf”);
//create formatted text
Aspose.Pdf.Facades.FormattedText text = new Aspose.Pdf.Facades.FormattedText("Total number of Pages: " + pinfo.NumberOfPages.ToString(),
System.Drawing.Color.White,
System.Drawing.Color.Black,
Aspose.Pdf.Facades.FontStyle.Courier,
Aspose.Pdf.Facades.EncodingType.Winansi,true,14);
mender.AddText(text,1, 1, 780);
mender.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}