Results 1 to 2 of 2
  1. #1
    Karlovsky120 is offline Member
    Join Date
    Jul 2013
    Posts
    15
    Rep Power
    0

    Default Evening out row length

    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.

  2. #2
    Karlovsky120 is offline Member
    Join Date
    Jul 2013
    Posts
    15
    Rep Power
    0

    Default Re: Evening out row length

    It seems that this is the answer to my question, but I don't know how to apply it:

    Link

    Is there a way I can insert widths array into iText Font or BaseFont or maybe another solution?

Similar Threads

  1. Length of an Array: length() or just length ?
    By Jack_Tauson_Sr in forum New To Java
    Replies: 8
    Last Post: 03-18-2013, 09:16 PM
  2. Difference between length() and length
    By mitra in forum New To Java
    Replies: 7
    Last Post: 07-28-2011, 01:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •