pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Lee <joe_h_...@yahoo.com>
Subject How to adjust font size by using setValue() to a PDTextbox
Date Thu, 20 Sep 2012 18:00:28 GMT

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.

Best Regards,

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);//=== field is a multi-line PDTextbox

        } catch (Exception e) {
        } finally {
if (PDFTemplate != null)
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message