Hi,

I sent out the same question to user's group several days ago, but didn't get 
any response. I send the same question to this group again and hope someone can 
direct me to the right direction to solve this problem.

Recently, I need to convert my project PDF library from iText to PDFBox. I had 
trouble to adjust the text in the PDTextbox (the display font size is too big). 
By using iText library, I can just use "setField" to write the text without 
worry about the font size, etc... But with PDFBox library, "setValue" method 
won't adjust the font size automatically (base on the size of PDFBox.) Is there 
a way I can set the configuration before calling the setValue method to make 
all the text fit into PDTextbox automatically? Thank you very much for your 
help.



P.S. If I click on the PDTextbox field after set the value, it displays the 
correct font size. But it will revert back to the original font size if the 
focus is not on that field.


Best Regards,
Joe


Code Example:

        try {
                PDFTemplate = PDDocument.load("orderFormTemplate.pdf");
                PDDocumentCatalog docCatalog = PDFTemplate.getDocumentCatalog();
                PDAcroForm acroForm = docCatalog.getAcroForm();


            PDField pdField = acroForm.getField(field);
    if (pdField != null) {
pdField.setValue(value);//=== value is a multi-line text and field is a 
multi-line PDTextbox
    }
:
:
PDFTemplate.save("newOrder.pdf");


        } catch (Exception e) {
    e.printStackTrace();
        } finally {
if (PDFTemplate != null)
  PDFTemplate.close();
    }

Reply via email to