Problem with PdfFileMend when adding FormattedText with IsWordWrap = true

When using PdfFileMend when adding FormattedText with IsWordWrap i cannot add FormattedText to the righthand side of an existing PDF file (beyond X coordinate > 450-500)


The version of PDF.Kit is 5.7

What will happen is that the text will be wrapped and malformed even though the FormattedText is added like this. The problem is easy to reproduce and I have attached a Visual Studio 2010 console application project that shows the problem. The code below should produce a square block of text but does not.

I can easily add FormattedText beyond X > 450-500 if WordWrap is turned off.

This is an important showstopper currently, any help is appreciated

Code example:
string appDirectory = AppDomain.CurrentDomain.BaseDirectory;

Aspose.Pdf.Kit.License l = new Aspose.Pdf.Kit.License();
l.SetLicense(“Aspose.Total.lic”);

PdfFileMend mender = new PdfFileMend(Path.Combine(appDirectory, “testinput.pdf”), Path.Combine(appDirectory, “testoutput.pdf”));

FormattedText text = new FormattedText(“Add some longer text to see the effect of word wrap!”, new FontColor(10, 100, 200), new FontColor(210, 210, 210), Aspose.Pdf.Kit.FontStyle.Courier, EncodingType.Winansi, true, 14);

mender.IsWordWrap = true;
mender.WrapMode = WordWrapMode.Default;

mender.AddText(text, 1, 450, 450, 500, 500);

mender.Close();



Any input on this? The only workaround i've found is to add fields using FormEditor and then flatten all fields, but this will not let me choose the Font that the customer originally decided on.

bariumab:
When using PdfFileMend when adding FormattedText with IsWordWrap i cannot add FormattedText to the righthand side of an existing PDF file (beyond X coordinate > 450-500)

The version of PDF.Kit is 5.7

What will happen is that the text will be wrapped and malformed even though the FormattedText is added like this. The problem is easy to reproduce and I have attached a Visual Studio 2010 console application project that shows the problem. The code below should produce a square block of text but does not.

I can easily add FormattedText beyond X > 450-500 if WordWrap is turned off.

This is an important showstopper currently, any help is appreciated

Code example:
string appDirectory = AppDomain.CurrentDomain.BaseDirectory;

Aspose.Pdf.Kit.License l = new Aspose.Pdf.Kit.License();
l.SetLicense("Aspose.Total.lic");

PdfFileMend mender = new PdfFileMend(Path.Combine(appDirectory, "testinput.pdf"), Path.Combine(appDirectory, "testoutput.pdf"));

FormattedText text = new FormattedText("Add some longer text to see the effect of word wrap!", new FontColor(10, 100, 200), new FontColor(210, 210, 210), Aspose.Pdf.Kit.FontStyle.Courier, EncodingType.Winansi, true, 14);

mender.IsWordWrap = true;
mender.WrapMode = WordWrapMode.Default;

mender.AddText(text, 1, 450, 450, 500, 500);

mender.Close();



Hi Christian,

I’m afraid, I couldn’t clearly understand that whether you’re having problem with the text placement or formatting of the text when it is wrapped. If you think that the text is malformed using Default mode, could you please try using ByWords mode? If it doesn’t resolve your issue then please elaborate it a little bit more, so we could help you out properly.

We’re sorry for the inconvenience.
Regards,

Hello

The problem is the placement. ByWords will not work either. It seems like there is a "hidden" margin on the PDF (i have tried several different PDFs) that forces the text to wrap before it should.

If you try the example I posted and compare the result:

FormattedText text = new FormattedText("Add some longer text to see the effect of word wrap!", new FontColor(10, 100, 200), new FontColor(210, 210, 210), Aspose.Pdf.Kit.FontStyle.Courier, EncodingType.Winansi, true, 14);


mender.IsWordWrap = true;
mender.WrapMode = WordWrapMode.Default;
// alternative 1 - will force the text to wrap even though it shouldnt. The text block is not square.
mender.AddText(text, 1, 450, 450, 500, 500);
// alternative 2 - will not wrap since it is not near the page "margin". The text block is square.
mender.AddText(text, 1, 250, 250, 300, 300);
--
Alternative 1 produces a faulty result. Please try this with a few different existing PDFs to see what I mean. I used your form filler example PDF and it produces the same result.

Hi Christian,

Thank you very much for sharing further details. I have reproduced this problem at my end and logged it as PDFKITNET-29086 in our issue tracking system. Our team will look into this issue and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,