Package org.apache.pdfbox.pdmodel.interactive.form

Examples of org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm


        {
            PDDocument fdeb = null;
            try
            {
                fdeb = PDDocument.load( filePDF );
                PDAcroForm form = fdeb.getDocumentCatalog().getAcroForm();
                PDTextbox field = (PDTextbox)form.getField( "f67_1" );
                field.setValue( "2" );
   
                String expected =
                    "/Tx BMC " +
                    "BT " +
View Full Code Here


        {
            PDDocument fdeb = null;
            try
            {
                fdeb = PDDocument.load( filePDF );
                PDAcroForm form = fdeb.getDocumentCatalog().getAcroForm();
                PDTextbox feld2 = (PDTextbox)form.getField( "Feld.2" );
                feld2.setValue( "Benjamin" );
   
                String expected =
                "1 1 0.8000000119 rg " +
                " 0 0 127.5 19.8299999237 re " +
                " f " +
                " 0 0 0 RG " +
                " 1 w " +
                " 0.5 0.5 126.5 18.8299999237 re " +
                " S " +
                " 0.5 g " +
                " 1 1 m " +
                " 1 18.8299999237 l " +
                " 126.5 18.8299999237 l " +
                " 125.5 17.8299999237 l " +
                " 2 17.8299999237 l " +
                " 2 2 l " +
                " 1 1 l " +
                " f " +
                " 0.75 g " +
                " 1 1 m " +
                " 126.5 1 l " +
                " 126.5 18.8299999237 l " +
                " 125.5 17.8299999237 l " +
                " 125.5 2 l " +
                " 2 2 l " +
                " 1 1 l " +
                " f " +
                " /Tx BMC  " +
                "BT " +
                "/Helv 14 Tf " +
                " 0 0 0 rg " +
                " 4 4.721 Td " +
                "(Benjamin) Tj " +
                "ET " +
                "EMC";
   
                testContentStreams( fdeb, feld2, expected );
   
                PDRadioCollection feld3 = (PDRadioCollection)form.getField( "Feld.3" );
                feld3.setValue("RB1");
                assertEquals( "RB1", feld3.getValue() );
                //assertEquals( ((PDCheckbox)feld3.getKids().get( 0 )).getValue(), "RB1" );
   
            }
View Full Code Here

            FDFDocument fdf = null;
            try
            {
                freedom = PDDocument.load( filePDF );
                fdf = FDFDocument.load( fileFDF );
                PDAcroForm form = freedom.getDocumentCatalog().getAcroForm();
                form.importFDF( fdf );
                PDTextbox feld2 = (PDTextbox)form.getField( "eeFirstName" );
                List kids = feld2.getKids();
                PDField firstKid = (PDField)kids.get( 0 );
                PDField secondKid = (PDField)kids.get( 1 );
                testContentStreamContains( freedom, firstKid, "Steve" );
                testContentStreamContains( freedom, secondKid, "Steve" );
   
                //the appearance stream is suppose to be null because there
                //is an F action in the AA dictionary that populates that field.
                PDField totalAmt = form.getField( "eeSuppTotalAmt" );
                assertTrue( totalAmt.getDictionary().getDictionaryObject( "AP" ) == null );
   
            }
            finally
            {
View Full Code Here

                usage();
            }
            else
            {
                pdf = PDDocument.load( args[0] );
                PDAcroForm form = pdf.getDocumentCatalog().getAcroForm();
                if( form == null )
                {
                    System.err.println( "Error: This PDF does not contain a form." );
                }
                else
                {
                    String fdfName = null;
                    if( args.length == 2 )
                    {
                        fdfName = args[1];
                    }
                    else
                    {
                        if( args[0].length() > 4 )
                        {
                            fdfName = args[0].substring( 0, args[0].length() -4 ) + ".fdf";
                        }
                    }
                    fdf = form.exportFDF();
                    fdf.save( fdfName );
                }
            }
        }
        finally
View Full Code Here

                usage();
            }
            else
            {
                pdf = PDDocument.load( args[0] );
                PDAcroForm form = pdf.getDocumentCatalog().getAcroForm();
                if( form == null )
                {
                    System.err.println( "Error: This PDF does not contain a form." );
                }
                else
                {
                    String fdfName = null;
                    if( args.length == 2 )
                    {
                        fdfName = args[1];
                    }
                    else
                    {
                        if( args[0].length() > 4 )
                        {
                            fdfName = args[0].substring( 0, args[0].length() -4 ) + ".xfdf";
                        }
                    }
                    fdf = form.exportFDF();
                    fdf.saveXFDF( fdfName );
                }
            }
        }
        finally
View Full Code Here

     * @throws IOException If there is an error setting the field.
     */
    public void setField( PDDocument pdfDocument, String name, String value ) throws IOException
    {
        PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
        PDAcroForm acroForm = docCatalog.getAcroForm();
        PDField field = acroForm.getField( name );
        if( field != null )
        {
            field.setValue( value );
        }
        else
View Full Code Here

     * @throws IOException If there is an error setting the data in the field.
     */
    public void importFDF( PDDocument pdfDocument, FDFDocument fdfDocument ) throws IOException
    {
        PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
        PDAcroForm acroForm = docCatalog.getAcroForm();
        acroForm.setCacheFields( true );
        acroForm.importFDF( fdfDocument );
    }
View Full Code Here

     * @throws IOException If there is an error getting the fields.
     */
    public void printFields( PDDocument pdfDocument ) throws IOException
    {
        PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
        PDAcroForm acroForm = docCatalog.getAcroForm();
        List fields = acroForm.getFields();
        Iterator fieldsIter = fields.iterator();

        System.out.println(new Integer(fields.size()).toString() + " top-level fields were found on the form");

        while( fieldsIter.hasNext())
View Full Code Here

     * @throws IOException If there is an error setting the data in the field.
     */
    public void importFDF( PDDocument pdfDocument, FDFDocument fdfDocument ) throws IOException
    {
        PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
        PDAcroForm acroForm = docCatalog.getAcroForm();
        acroForm.setCacheFields( true );
        acroForm.importFDF( fdfDocument );
    }
View Full Code Here

        if( destCatalog.getOpenAction() == null )
        {
            destCatalog.setOpenAction( srcCatalog.getOpenAction() );
        }

        PDAcroForm destAcroForm = destCatalog.getAcroForm();
        PDAcroForm srcAcroForm = srcCatalog.getAcroForm();
        if( destAcroForm == null )
        {
            cloneForNewDocument( destination, srcAcroForm );
            destCatalog.setAcroForm( srcAcroForm );
        }
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.