Writing Text Fragments causing extra fragments to overlay drawn lines

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)

@david_j_meyer2_boeing_com

Would you please check the attached PDF which was generated using 24.4 version in our environment and share screenshots with us if you still notice issues in it?

I’m not seeing an attachment other than the documents I included. I am currently using Aspose.PDF 23.1.1 we are working through procurement for a new an updated license.

@david_j_meyer2_boeing_com

Sorry for the inconvenience. Here is the attached file for your kind reference.
TextWritten0.pdf (49.7 KB)

Yes there are empty text fragments written to this document too. If you notice the lines are missing or different visibly that is an extra empty fragment being written.

If we could specify the ZIndex to push the text fragments to the lowest level that would resolve our problem too.

If you look at the BlankExample.pdf and the document you created. You will see where the issues are. I have highlighted them in the latest attachment to this post.

AsposeWrittenText-error-highlights.PNG (11.6 KB)

@david_j_meyer2_boeing_com

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-57164

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

I think I know what the problem is. The extra artifacts I was seeing is caused by the TextFragment objects being drawn because i was setting a background color. Setting a background color to a TextFragment was creating a rectangle around the text, which was what I was observing in Adobe Acrobat.

The interestingly it looks like because of the page rotation the artifacts where left where they would exist prior to rotating. At least that’s what it looks like.

Hope that helps.

@david_j_meyer2_boeing_com

Thanks for sharing this information. The ticket has been updated accordingly and we will surely inform you once we have some updates about its resolution. We apologize for your inconvenience.