Hi,

> Am 16.07.2015 um 20:28 schrieb jarrod <[email protected]>:
> 
> Hello Maruan,
> 
> In regards to the AutoSize changes;
> The text fits better (no longer is cutoff by the field boundaries) :). The 
> text is higher than normal, as mentioned by another, but is sufficient for my 
> use.

I know and I'm investigating how to fix that (I have the same issue with some 
test files I'm using but thought I commit anyway because of the improvements)

> 
> Unfortunately, when converting my project from 1.8.9 to the latest 2.0.0 
> snapshot, I've encountered some new problems. I will send those in a new 
> email.

Please do so or open an issue at https://issues.apache.org/jira/browse/PDFBOX/

BR
Maruan

> 
> Thanks,
> 
> Jarrod
> --------------------------------------------
> On Thu, 7/16/15, Maruan Sahyoun <[email protected]> wrote:
> 
> Subject: Re: Font AutoSize Issue
> To: [email protected]
> Date: Thursday, July 16, 2015, 7:54 AM
> 
> Hi Jarod,
> 
>> Am 10.07.2015 um 23:11
> schrieb jarrod <[email protected]>:
>> 
>> Hello Maruan,
>> 
>> I understand what
> you describing. Its unfortunate it isn't listed in the
> spec so everyone can be the same. I imagine the calculation
> could get quite complicated. Yes I can use a newer version.
> I'm not very familiar with software life cycle, will I
> need to wait for the RC for a fix? If so, any guesses as to
> when that might be?
> 
> I
> committed some changes to the text formatting specially for
> autosize text. You can either build from source or use the
> snapshot as soon as it is available at 
> http://pdfbox.apache.org/download.cgi#snapshots
> <http://pdfbox.apache.org/download.cgi#snapshots>
> 
> Please let me know if it
> improves the output you get.
> 
> BR
> Maruan
> 
>> 
>> Have a great weekend
> and thanks for the help!
>> 
>> Jarrod
>> 
> --------------------------------------------
>> On Fri, 7/10/15, Maruan Sahyoun <[email protected]>
> wrote:
>> 
>> Subject:
> Re: Font AutoSize Issue
>> To: [email protected]
>> Date: Friday, July 10, 2015, 3:55 PM
>> 
>> Hi,
>> 
>>> Am 10.07.2015 um
> 16:06 schrieb jarrod
>> <[email protected]>:
>>> 
>>> Evan,
>>> 
>>> I tested
> doing the
>> same thing but decided it
> wasn't a very good solution in
>> my
> case. There are a lot of fields to modify over multiple
>> pages across numerous pdf's that are
> updated annually.
>> Additionally, in my
> case the length of text can be fairly
>> 
> dynamic and fixing a font could be problematic for users
>> doing manual data entry/correction. Thanks
> for your added
>> input. Hopefully Mr
> Sahyoun has a solution for us.
>> 
>> I had a quick look. The issue
>> is not that the autosizing doesn't
> work. It's the
>> difference in
> calculating the available field size.
>> 
> Unfortunately, as this is not documented in the PDF spec
> one
>> has to compare the content
> generated by Adobe and handle it
>> from
> there. (e.g. Adobe adds padding to the fields bounding
>> box but only to a certain limit, there are
> some edge cases
>> ….)  Anyway, I think
> there will can achieve a result
>> which
> is closer to what Adobe achieves using the data file
>> and templates provided.
>> 
>> Do
>> you have to stay on 1.8.x or would you be
> able to work with
>> the 2.0.0-SNAPSHOT
> version? We are also planning to have an
>> RC out soon.
>> 
>> As I'm on
>> travel
> it will be start of next week until I can handle
>> it.
>> 
>> BR
>> Maruan
>> 
>> 
>>> 
>>> Thanks,
>>> 
>>> Jarrod
>>> 
>> 
> --------------------------------------------
>>> On Fri, 7/10/15, Evan Williams <[email protected]>
>> wrote:
>>> 
>>> Subject:
>> Re: Font
> AutoSize Issue
>>> To: [email protected]
>>> Date: Friday, July 10, 2015, 8:35
> AM
>>> 
>>> I
> actually have seen
>> the exact same
>>> behavior in 1.8.9.
>>> 
>>> I dealt with
> it by
>> just fixing the forms in Acrobat
> so that
>>> the fonts have
>>> a
>> fixed size,
> because I did not have the time or the energy
>>> to deal with
>>> 
> it. But
>> autosized fonts definitely did
> not work for me when
>>> filling out
>>> forms in
>> 
> 1.8.9.
>>> 
>>> If
> it
>> would be helpful and Jarrod does not
> have a good
>>> example document I
>>> 
>> would be happy
> to publish one of mine.
>>> 
>> 
>>> Thanks.
>>> 
>>> On Fri, Jul
> 10, 2015 at 4:19 AM, Maruan
>> Sahyoun
> <[email protected]>
>>> wrote:
>>> 
>>>> Hi,
>>>> 
> 
>>>> 
>>>>> Am
>> 
> 10.07.2015 um 00:32 schrieb jarrod <[email protected]>:
>>>>> 
>>>>> 
>> I'm
> evaluating pdfbox for filling in form fields
>>> from a template pdf
>>>> file.
>>>>> 
>>>>> From what I can tell, pdfbox
> does
>> not support
>>> autosize font. While it
>>>> will retain the font size 0
> setting,
>> the text that is
>>> placed into the
>>>> fields is not autosized (until
> you
>> alter the value
>>> manually).
>>>>> 
>>>>> 
>> Option
> A:
>>>>> Is there some kind of
>> command to execute before
>>> saving the
>> pdf to
> force
>>>> it to autosize?
>>>>> 
>>>>> 
>> Option
> B:
>>>>> Do some math and
>> calculate a new font size. I've
>>> 
>> done this (see
> code
>>>> below) but you
>> obviously lose the ability to autosize
>>> 
>> if the user ends
> up
>>>> modifying a
>> value.
>>>>> Is
> there a way to do
>> this math and set the
> initial
>>> display
>> font size but
>>>> 
> leave the DA alone
>> with autosize
> set?
>>>>> I'm
>> guessing this would be done by setting
> some
>>> other COSName String
>>>> similar to setting the
> COSName.DA.
>> However, I can't
>>> find much
>> 
> information
>>>> on these.
>>>> 
>>>> 
>>>> which version of PDFBox are you
> using?
>> Do you have a
>>> sample empty PDF and
>>>> filled out one together with some
> code
>> how you do the
>>> form filling?
>>>> 
>>>> Both
> 1.8.9
>> and 2.0.0-SNAPSHOT should
> support
>>> 
>> 
> autosizing.
>>>> 
>>>> BR
>>>> 
> Maruan
>>>> 
>>>>> 
>>>>> Any help is appreciated. Code
> is
>> below;
>>>>> 
>>>>> //item.field_value is the
> value
>> I'm sticking into
>>> the form field
>>>>> 
>>>>> if
>> (field
> instanceof PDTextbox)
>>>>> 
>> {
>>>>>      
>    int len =
>>> 
> item.field_value.length();
>>>>>          if
> (len>2)
>>>>>      
>    {
>>>>>        
>      
>>>  
>    COSDictionary dict =
>>> 
> field.getDictionary();
>>>>>    
>          
>>>  
>    COSString defaultAppearance =
>> (COSString)
>>>> 
> 
>> 
> dict.getDictionaryObject(COSName.DA);
>>>>>          
>    
>>>      if
> (defaultAppearance != null)
>>>>>          
>    
>>>      {
>>>>>     
>>  
>          
>>>        
>    //split
>> the DA to
>>> grab the font size
>>>>>            
>    
>>>        
>    String[] da =
>>>> 
>> defaultAppearance.getString().split("
> ");
>>>>>            
>    
>>>        
>    List<String>
>>> 
> da2 = new ArrayList<String>();
>>>>> 
>>>>>     
>>  
>          
>>>        
>    //loop
>> through and
>>> remove any empty strings
>>>>>            
>    
>>>        
>    // because for some
>>> 
> reason when the font size is 0
>>>> 
> there is an empty extra string in the
>> 
> way
>>>>>            
>    
>>>        
>    for(int x=0;
>>> 
> x<da.length; x++)
>>>>>    
>            
>>>      
>      {
>>>>>      
>          
>>>        
>        
>>>  
>    if (da[x].length()!=0)
>>>>>            
>    
>>>              
>    
>>>        
>    da2.add(da[x]);
>>>>>            
>    
>>>        
>    }
>>>>>        
>        
>>>        
>    //Move back to a
>>> 
> String[] (I'm new to java)
>>>>>            
>    
>>>        
>    da =
>>> 
>> da2.toArray(da);
>>>>> 
>>>>>            
>    
>>>        
>    if (da.length >=
>>> 
> 2) //only process if there are at
>>>> least two characters
>>>>>            
>    
>>>        
>    {
>>>>>        
>        
>>>          
>      
>>>  
>    if (da[1].equals("0")) //If
>> font size is
>>>> 
> actually autosized
>>>>>      
>          
>>>        
>        
>>>  
>    {
>>>>>     
>>            
>>>                 
>> 
>>>        
>    COSArray
>>> 
> fieldAreaArray =
>>>> 
>> (COSArray)
> dict.getDictionaryObject(COSName.RECT);
>>>>>            
>    
>>>              
>    
>>>        
>    PDRectangle rect =
>>> 
> new
>>>> 
>> 
> PDRectangle(fieldAreaArray);
>>>>>   
>>    
>          
>>>        
>       
>>    
>>>            float width
> =
>>> rect.getWidth();
>>>>> 
>>>>>     
>>  
>          
>>>        
>         
>> 
>>>            int size =
>>> (int)(width / len *
>>>> 1.92); //doing stupid math to
> estimate
>> new font size
>>>>> 
>>>>>            
>    
>>>              
>    
>>>        
>    if (size > 12)
>>>>>            
>    
>>>              
>    
>>>            
>    
>>>      size
> = 12;
>>>>>            
>    
>>>              
>    
>>>        
>    else if (size <
>>> 
> 8)
>>>>>         
>>        
>>>                  
>>>                
>>>      size = 8;
>>>>> 
>>>>>     
>>  
>          
>>>        
>         
>> 
>>>            String
> customSize =
>>> "/Helv "
> +
>>>> size + " Tf 0
> g";
>>>>> 
>>>>>     
>>  
>          
>>>        
>         
>> 
>>>        
>>>     
>> 
> dict.setString(COSName.DA,
>>>> 
>> customSize); //Set the new font size
> here
>>>>>            
>    
>>>              
>    
>>>        
>    field = new
>>> 
> PDTextbox(acroForm,
>>>> dict);
> //Create as a new field (as
>> seen in
> other
>>> threads)
>>>>>            
>    
>>>            
>    
>>>      }
>>>>>     
>>  
>          
>>>        
>    }
>>>>>        
>      
>>>  
>    }
>>>>>     
>>      }
>>>>> }
>>>>> 
> field.setValue(item.field_value);
>> //Set
> the field
>>> value
>>>>> 
>>>>> 
>> 
> Jarrod
>>>>> 
>>>>> 
>>> 
>> 
> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [email protected]
>>>>> For additional commands,
> e-mail:
>> [email protected]
>>>>> 
>>>> 
> 
>>>> 
>>>> 
> 
>>> 
>> 
> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail:
> [email protected]
>>>> 
>>>> 
>>> 
>>> 
>>> -- 
>>> *Evan
>> Williams*
>>> Sr.
> Software Engineer
>>> [email protected]
>>> 
>>> 
> *www.ZappRx.com
>> <http://www.zapprx.com/>*
>>> 
>> 
>>> 
>>> 
>> 
> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>> 
>> 
>> 
>> 
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
>> 
>> 
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to