You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Lorena Leishman <lo...@yahoo.com.INVALID> on 2015/01/09 17:04:56 UTC
Missing classes
Hello I installed pdfbox-app-1.8.8.jar and I have been able to run any example codes successfully. I am working on this one and I get "cannot find symbol" on import org.apache.pdfbox.pdmodel.interactive.form.PDFieldTreeNode;import org.apache.pdfbox.pdmodel.interactive.form.PDTextField;
Are these classes in a different jar?
Code:
package org.apache.pdfbox.examples.acroforms;import java.io.File;import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
import org.apache.pdfbox.pdmodel.interactive.form.PDField;
import org.apache.pdfbox.pdmodel.interactive.form.PDFieldTreeNode;
import org.apache.pdfbox.pdmodel.interactive.form.PDTextField;
public class FillTestField { public static void main(String[] args) throws IOException { String formTemplate = "Users/Dad/Desktop/TCRM/game plan 12-16.pdf"; String filledForm = "Users/Dad/JavaTest/game plan 12-16.pdf"; // load the document PDDocument pdfDocument = PDDocument .load(new File(formTemplate),null); // get the document catalog PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm(); // as there might not be an AcroForm entry a null check is necessary if (acroForm != null) { // Retrieve an individual field and set it's value. PDTextField field = (PDTextField) acroForm.getField( "Goal" ); field.setValue("Testing"); // If a field is nested within the form tree a fully qualified name // might be provided to access the field. field = (PDTextField) acroForm.getField( "fieldsContainer.nestedSampleField" ); field.setValue("Text Entry"); }
// Save and close the filled out form. pdfDocument.save(filledForm);
pdfDocument.close(); }}
Re: Missing classes
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,
PDFieldTreeNode and PDTextField are for PDFBox 2.0
for 1.8 use PDField and PDTextbox instead [http://pdfbox.apache.org/docs/1.8.8/javadocs/org/apache/pdfbox/pdmodel/interactive/form/package-summary.html]
BR
Maruan
Am 09.01.2015 um 17:04 schrieb Lorena Leishman <lo...@yahoo.com.INVALID>:
> Hello I installed pdfbox-app-1.8.8.jar and I have been able to run any example codes successfully. I am working on this one and I get "cannot find symbol" on import org.apache.pdfbox.pdmodel.interactive.form.PDFieldTreeNode;import org.apache.pdfbox.pdmodel.interactive.form.PDTextField;
>
> Are these classes in a different jar?
> Code:
> package org.apache.pdfbox.examples.acroforms;import java.io.File;import java.io.IOException;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
> import org.apache.pdfbox.pdmodel.interactive.form.PDField;
> import org.apache.pdfbox.pdmodel.interactive.form.PDFieldTreeNode;
> import org.apache.pdfbox.pdmodel.interactive.form.PDTextField;
>
>
> public class FillTestField { public static void main(String[] args) throws IOException { String formTemplate = "Users/Dad/Desktop/TCRM/game plan 12-16.pdf"; String filledForm = "Users/Dad/JavaTest/game plan 12-16.pdf"; // load the document PDDocument pdfDocument = PDDocument .load(new File(formTemplate),null); // get the document catalog PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm(); // as there might not be an AcroForm entry a null check is necessary if (acroForm != null) { // Retrieve an individual field and set it's value. PDTextField field = (PDTextField) acroForm.getField( "Goal" ); field.setValue("Testing"); // If a field is nested within the form tree a fully qualified name // might be provided to access the field. field = (PDTextField) acroForm.getField( "fieldsContainer.nestedSampleField" ); field.setValue("Text Entry"); }
> // Save and close the filled out form. pdfDocument.save(filledForm);
> pdfDocument.close(); }}
>
>
Fw: Missing classes
Posted by Lorena Leishman <lo...@yahoo.com.INVALID>.
I meant I haven't been able to run any example code successfully.
Hello I installed pdfbox-app-1.8.8.jar and I have been able to run any example codes successfully. I am working on this one and I get "cannot find symbol" on import org.apache.pdfbox.pdmodel.interactive.form.PDFieldTreeNode;import org.apache.pdfbox.pdmodel.interactive.form.PDTextField;
Are these classes in a different jar?
Code:
package org.apache.pdfbox.examples.acroforms;import java.io.File;import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
import org.apache.pdfbox.pdmodel.interactive.form.PDField;
import org.apache.pdfbox.pdmodel.interactive.form.PDFieldTreeNode;
import org.apache.pdfbox.pdmodel.interactive.form.PDTextField;
public class FillTestField { public static void main(String[] args) throws IOException { String formTemplate = "Users/Dad/Desktop/TCRM/game plan 12-16.pdf"; String filledForm = "Users/Dad/JavaTest/game plan 12-16.pdf"; // load the document PDDocument pdfDocument = PDDocument .load(new File(formTemplate),null); // get the document catalog PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm(); // as there might not be an AcroForm entry a null check is necessary if (acroForm != null) { // Retrieve an individual field and set it's value. PDTextField field = (PDTextField) acroForm.getField( "Goal" ); field.setValue("Testing"); // If a field is nested within the form tree a fully qualified name // might be provided to access the field. field = (PDTextField) acroForm.getField( "fieldsContainer.nestedSampleField" ); field.setValue("Text Entry"); }
// Save and close the filled out form. pdfDocument.save(filledForm);
pdfDocument.close(); }}