PdfFileMend.AddText with multi-line text

Can I use multi-line text with PdfFileMend.AddText?

If so can you provide me with a sample how it is coded in C#?

Thanks!

Hello Scott,

Multi-line text can be added using PdfFileMend.AddText. Please see the following code snippet.

string inputFile = @"C:\pdftest\Nayyer.pdf";
string outputFile = @"C:\pdftest\Nayyer_1.pdf";

PdfFileInfo fileInfo = new PdfFileInfo(@inputFile);
float height = fileInfo.GetPageHeight(1);
float width = fileInfo.GetPageWidth(1);
int rotation = fileInfo.GetPageRotation(1); //get the page rotation
string couplet1 = "1st line added,"+
"2nd Line, 3rd line and 4th line";

PdfFileMend mendor = new PdfFileMend(inputFile, outputFile);
mendor.IsWordWrap = true;
mendor.AddText(new FormattedText(couplet1), 1, 400, 700);

If you set the value for IsWordWrap to false, all the string will be added in a single line, and if value is set to True, new line will be started once the line reaches right Margin of the page.

What I am trying to do is add text that is multi-line even though it is not past the right margin of the document.

See attached document, number 1 on the left side is text I inserted and I would like to make the text 2 lines if it goes past a certain point on the document.

Is this possible?

Thanks!

Scott

Hello Scott,

There is an other way to accomplish this, please try the following code snippet.

Stamp aStamp = new Stamp();
FormattedText formatText = new FormattedText();
formatText.AddNewLineText("This is a simpel text ");
formatText.AddNewLineText("This is a 2nd line");
aStamp.SetOrigin(100, 700);
aStamp.BindLogo(formatText);
PdfFileStamp stamper = new PdfFileStamp("C:\\pdftest\\ReplacedText.pdf", "C:\\pdftest\\AdhereText.pdf");
stamper.AddStamp(aStamp);
stamper.Close();

you can add as many lines using AddNewLineText(); For more information kindly visit http://www.aspose.com/documentation/file-format-components/aspose.pdf.kit-for-.net-and-java/aspose.pdf.kit.stamp.bindlogo.html

That is close, but what I would like to do is add this text:

This is a simple text and if this is too long to fit in the space provided move to the next line.

If the above is too long to fit in the space provided move to the next line.

See attached output desired.

Thanks!

Hello Scott,

Have you tried using

formatText.AddNewLineText("This is a simple text");
formatText.AddNewLineText("and if this is too");
formatText.AddNewLineText("long to fit in the ");
formatText.AddNewLineText("space provided move ");
formatText.AddNewLineText("to the next line");

Its just a work around, in fact WordWrap is not working properly, I will discuss it with development and will let you update with its status. Sorry for inconvenience.

Hello Scott,

I have discussed the PdfFileMend.IsWordWrap issue with development team and we have observed that there are some issues in the feature. I have logged it in our defect management system as PDFKITNET-5482 .We try to resolve this issue as soon as possible and will let you know about the status. Sorry for the inconvenience.

Hi,

The issue PdfKitNet-5482 has been resolved, Please download and try the attachment "Aspose.pdf.Kit.rar" from <A href="https://forum.aspose.com/t/126657</A></P> <P>Thanks,</P>