I am working with PDF and I need to insert text into the PDF from an RTF file.
This is no problem with the DrawText() function as descibed in the doc.
However, if I want to insert large amounts of text, Acrobat gives an error for the PDF.
Over 25000 characters and this occurs.
My Gdpicture status returns ok to the DrawText() and the saveFile() but when I open the PDF I have , this page contains an error and may bot be correctly displayed.
What are the limitations of DrawText() ? Or even the limitations of inserting text on to one page ?
For this type of insertion is there another more adpated approach to inserting text ?
For the moment I will split the text and DrawText() it at different points in the PDF, but I would like to understand more about DrawText()
I have been searching in the forum and the documentation for a information but have not been able to find enough.
Many thanks for any info.
Clodagh
Code: Select all
GdPicturePDF oGdPicturePDF = new GdPicturePDF();
GdPictureStatus oPDFStatus;
String text = "";
bool lSuccess = false;
if ((oGdPicturePDF.LoadFromFile(sFileName, true) == GdPictureStatus.OK))
{
//retrieve text to insert
text = GetRTFContents(sFileName);
if(!String.IsNullOrEmpty(text))
{
oGdPicturePDF.SelectPage(1);
string font_res_name = oGdPicturePDF.AddTrueTypeFont("Arial", false, false, false);
oGdPicturePDF.SetTextMode(PdfTextMode.PdfTextModeFill);
oGdPicturePDF.SetTextSize(10);
oGdPicturePDF.SetFillColor(255, 0, 0, 0);
oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint);
oPDFStatus = oGdPicturePDF.DrawText(font_res_name, 1, 1, text);
if (oPDFStatus == GdPictureStatus.OK)
{
oPDFStatus = oGdPicturePDF.SaveToFile(sFileName);
if (oPDFStatus == GdPictureStatus.OK)
{
lSuccess = true;
}
else
{
oLog.Write("[InsertTextIntoPDF] Problem saving file : " + oPDFStatus, cLog.LEVEL._ERROR);
}
}
else
{
oLog.Write("[InsertTextIntoPDF] Problem inserting text : " + oPDFStatus, cLog.LEVEL._ERROR);
}
}
oGdPicturePDF.CloseDocument()