Package org.pdfbox.pdmodel.fdf

Examples of org.pdfbox.pdmodel.fdf.FDFDocument


    }

    private void importXFDF( String[] args ) throws Exception
    {
        PDDocument pdf = null;
        FDFDocument fdf = null;

        try
        {
            if( args.length != 3 )
            {
                usage();
            }
            else
            {
                ImportFDF importer = new ImportFDF();
                pdf = PDDocument.load( args[0] );
                fdf = FDFDocument.loadXFDF( args[1] );

                importer.importFDF( pdf, fdf );
                pdf.save( args[2] );
                fdf.save( "tmp/outputXFDFtoPDF.fdf");
            }
        }
        finally
        {
            close( fdf );
View Full Code Here


     * @return An FDF document used to export the document.
     * @throws IOException If there is an error when exporting the document.
     */
    public FDFDocument exportFDF() throws IOException
    {
        FDFDocument fdf = new FDFDocument();
        FDFCatalog catalog = fdf.getCatalog();
        FDFDictionary fdfDict = new FDFDictionary();
        catalog.setFDF( fdfDict );
       
        List fdfFields = new ArrayList();
        List fields = getFields();
View Full Code Here

     * @throws Exception If there is an error while testing.
     */
    public void testFDFFreedomExpressions() throws Exception
    {
        PDDocument freedom = null;
        FDFDocument fdf = null;
        try
        {
            freedom = PDDocument.load( "test/input/FreedomExpressions.pdf" );
            fdf = FDFDocument.load( "test/input/FreedomExpressions.fdf" );
            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
        {
            if( freedom != null )
            {
                freedom.close();
            }
            if( fdf != null )
            {
                fdf.close();
            }
        }
    }
View Full Code Here

     *
     * @throws IOException If there is an error getting the document.
     */
    public FDFDocument getFDFDocument() throws IOException
    {
        return new FDFDocument( getDocument() );
    }
View Full Code Here

    }

    private void exportXFDF( String[] args ) throws Exception
    {
        PDDocument pdf = null;
        FDFDocument fdf = null;

        try
        {
            if( args.length != 1 && args.length != 2 )
            {
                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

    }

    private void importFDF( String[] args ) throws Exception
    {
        PDDocument pdf = null;
        FDFDocument fdf = null;

        try
        {
            if( args.length != 3 )
            {
View Full Code Here

    }

    private void exportFDF( String[] args ) throws Exception
    {
        PDDocument pdf = null;
        FDFDocument fdf = null;

        try
        {
            if( args.length != 1 && args.length != 2 )
            {
                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

TOP

Related Classes of org.pdfbox.pdmodel.fdf.FDFDocument

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.