I am writing text fragments to a location and there seems to be an extra fragment created. It ends up sitting over the existing line and i cant determine where its coming from. I also have no way to “send back” so its on bottom of the stack.
I have attached the following files:
-
BlankExample.pdf - the original document that i am writing too.
-
TextWritten0.pdf - The document after I have written text fragments to it.
-
TextWrittenExtraElementAppears.PNG - screen capture showing the extra empty fragment causing issues.
-
TextWrittenExtraElementAppears-2.PNG - screen capture showing the second locations extra empty fragment causing issues.
-
TextWrittenExtraElementAppears-3.PNG - screen capture showing the second locations extra empty fragment causing issues. There is also a new line character in this string that is not being recognized.
Here is the code I am using to write the content.
// Procedure writing text fragments
public static void AddText(Page pdfPage, float x_indent, float y_indent, String content)
{
// Create text fragment
TextFragment textFragment = new TextFragment(content);
textFragment.Position = new Position(x_indent, y_indent);
textFragment.ZIndex = -1;
textFragment.TextState.FontSize = 9.5f;
textFragment.TextState.Font = FontRepository.FindFont("Courier");
textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.White);
textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black);
textFragment.TextState.LineSpacing = 1f;
textFragment.IsInLineParagraph = false;
// Create TextBuilder object
TextBuilder textBuilder = new TextBuilder(pdfPage);
// Append the text fragment to the PDF page
textBuilder.AppendText(textFragment);
return;
}
Document dave = new Document(@“C:\Users\Desktop\ForAspose\BlankExample.pdf”);
AddText(dave.Pages[1], 386.467f, 585.221f, “EXPORT”);
AddText(dave.Pages[1], 386.467f, 575.122f, “CONTROL”);
AddText(dave.Pages[1], 386.467f, 565.023f, “COM”);
AddText(dave.Pages[1], 19.506f, 585.221f, “SUPPLIER CUSTOM MODULE LIST”);
AddText(dave.Pages[1], 19.506f, 57.813f, "(CONTINUED ON NEXT PAGE)\r\nSOMETHING COOL - SEE STANDARD NOTES FOR THOUGHTS ON DATA IN MY HEAD ");
// Save the new document
dave.Save(@“C:\Users\Desktop\ForAspose\TextWritten0.pdf”);
Thanks, Dave
BlankExample.pdf (50.6 KB)
TextWrittenExtraElementAppears.PNG (3.8 KB)
TextWrittenExtraElementAppears-2.PNG (4.8 KB)
TextWrittenExtraElementAppears-3.PNG (5.6 KB)
TextWritten0.pdf (49.1 KB)