You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "marc.sauget@laposte.net" <ma...@laposte.net> on 2011/09/13 13:57:24 UTC

Problem of use with setValue for a PDField

Hi,

I m testing the pdfbox librairy and my principal interrest is to manage field into pdf document.

I juste want to implement the Cookbooks specific to this problem : http://www.docjar.com/html/api/org/apache/pdfbox/examples/fdf/SetField.java.html


I have not any probleme to create a new documents or to open an existing, but, when i wan't add some information in a field I have the following problems :

-----------------------------------------
Exception in thread "main" java.io.IOException: Error: Don't know how to calculate the position for non-simple fonts
    at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.getTextPosition(PDAppearance.java:616)
    at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.insertGeneratedAppearance(PDAppearance.java:380)
    at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.setAppearanceValue(PDAppearance.java:281)
    at org.apache.pdfbox.pdmodel.interactive.form.PDVariableText.setValue(PDVariableText.java:131)
-----------------------------------------


I use exactly the same code as the exemple :

----------------------------------------------------------------
   try
        {
           
             PDDocument pdf = PDDocument.load("testForm.pdf");
             
             PDDocumentCatalog docCatalog = pdf.getDocumentCatalog();
             PDAcroForm acroForm = docCatalog.getAcroForm();
             PDField field = acroForm.getField("Date");
                       
             if( field != null )
             {
                 field.setValue("test");
             }else
             {
                 System.out.println("Champs INS not found\n");
             }

             pdf.save("testB.pdf");
             pdf.close();
        }
---------------------------------------

I have read brievely  read the source code of this part of pdfbox but I have not find a solution to my problem.
I just want to know is ths problem is normal (I do a bad use of pdfbox or I have forget anythink) or if the proble coold be appar with a "wrong" pdf file.


Thanks a lot.

Best regard

Marc S.


Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ?
Je crée ma boîte mail www.laposte.net