Hi PDFium Team,
I have been working with PDFium's page content editing and regeneration functionality and would like to propose an enhancement related to the TJ text-showing operator.
PDFium supports parsing and rendering both Tj and TJ. However, when page contents are regenerated after editing, text originally represented using TJ arrays is serialized using Tj, effectively flattening the positioning adjustments present in the TJ array.
I have implemented support for generating TJ arrays during page content regeneration, preserving relevant glyph positioning and spacing adjustments where appropriate.
I would be interested in contributing this enhancement upstream. Before preparing a focused CL with tests, I would appreciate feedback on whether this functionality aligns with PDFium's design goals and whether there is a preferred approach for implementing it in the page content generation path.
Thanks
Amit Kumar Pathak
HI Lei,
Thanks for pointing me to this change.
I compared it with my implementation and realized that my PDFium branch was based on an older revision that predates this change.
There is one difference in the approach, though. My implementation tracks whether the original text object was represented using TJ (HasTJ()) and reconstructs it during content regeneration (RebuildTJStream()). Text originally represented using Tj continues to be generated as Tj.
So the behavior is essentially:
Original Tj regenerated as Tj
Original TJ regenerated as TJ
From my understanding, the referenced upstream change generates TJ based on the character positioning/kerning information and does not attempt to preserve the original Tj vs TJ operator choice.
My original goal was therefore slightly different: preserve the original text-showing operator representation during page content regeneration, in addition to retaining the positioning information for TJ.
Would preserving the original Tj/TJ representation be useful from PDFium's perspective or is canonicalizing regenerated text to TJ intentional and by Design??
Thanks
Amit Kumar Pathak