To the admins: I know I have asked a similar question before, but I'm going for another angle. Please let this be for a while to get some replies, then you can merge it with the other topic. Thank you.
So I have to copy a content of a JTextArea to a PDF document 1:1 scale, or at least as close as possible to it.
I'm adding the text to PDF using iText and I'm using one of the non-text layers so I could give the text an absolute position using the coordinate system.
I'd also like to mention here that I have one *.ttf file that I'm using for both of the fonts, the on in the JTextArea and the one in the PDF.
Regarding to the height, I managed to make it perfect, however when it comes to the width, problems occur.
You see, the spacing values for the both fonts are be different. And not "my spacing is wider/narrower than yours" different. It seems that spacing varies depending on a character. In some cases spacing in JTextArea is wider than in the PDF, and in other it's the opposite.
Now, I need to somehow make the rows to be of the same length. One option is to convert the PDF row into an image and then strecth it. However, I don't know how would that look, and if it would disable user to select that row as a text, that would be a deal-breaker.
Adjusting the spacing values row-specific doesn't help because the step to the closest values of spacing is simply too big.
Do any of you have any ideas on how I could mend this? I'm willing to change the spacing values for each individual letter and character, if that is possible...
Also, to get the question more attention, I crossposted the question here.