Package org.apache.pdfbox.pdmodel

Examples of org.apache.pdfbox.pdmodel.PDDocument.save()


                        StandardProtectionPolicy spp =
                            new StandardProtectionPolicy(ownerPassword, userPassword, ap);
                        spp.setEncryptionKeyLength(keyLength);
                        document.protect(spp);
                    }
                    document.save( outfile );
                }
                else
                {
                    System.err.println( "Error: Document is already encrypted." );
                }
View Full Code Here


                    {
                        throw new IOException( "Unknown argument:" + args[i] );
                    }
                }
                doc = app.createPDFFromText( new FileReader( args[args.length-1] ) );
                doc.save( args[args.length-2] );
            }
        }
        finally
        {
            if( doc != null )
View Full Code Here

                pdf = PDDocument.load( args[0] );
                fdf = FDFDocument.load( args[1] );
                importer.importFDF( pdf, fdf );

                pdf.save( args[2] );
            }
        }
        finally
        {
            close( fdf );
View Full Code Here

                    document.openProtection(decryptionMaterial);
                    AccessPermission ap = document.getCurrentAccessPermission();
                    if(ap.isOwnerPermission())
                    {
                        document.setAllSecurityToBeRemoved(true);
                        document.save( outfile );
                    }
                    else
                    {
                        throw new IOException(
                        "Error: You are only allowed to decrypt a document with the owner password." );
View Full Code Here

                    COSObject obj = doc.getDocument().getObjectFromPool(key);
                    obj.setObject(next.getObject());
                }
                doc.getDocument().removeObject(new COSObjectKey(objStream));
            }
            doc.save(outputFilename);
        } catch(Exception e) {
            System.out.println("Error processing file: " + e.getMessage());
        } finally {
            if(doc != null)
                try { doc.close(); } catch(Exception e) { }
View Full Code Here

                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
        {
View Full Code Here

                    cosStream.getUnfilteredStream();
                    cosStream.setFilters(null);
                }
            }
            doc.getDocumentCatalog();
            doc.save( out );
        }
        finally
        {
            if( doc != null )
            {
View Full Code Here

        PDDocument document = PDDocument.load(new ByteArrayInputStream(inputFileWithEmbeddedFileAsByteArray));
        PDDocument encryptedDoc = encrypt(keyLength, sizePriorToEncr, document, "ContainsEmbedded-", permission, nonSeq, userpassword, ownerpassword);

        File decryptedFile = new File(testResultsDir, "DecryptedContainsEmbedded-" + keyLength + "-bit.pdf");
        encryptedDoc.setAllSecurityToBeRemoved(true);
        encryptedDoc.save(decryptedFile);

        File extractedEmbeddedFile = extractEmbeddedFile(new FileInputStream(decryptedFile), "decryptedInnerFile-" + keyLength + "-bit.pdf");

        Assert.assertEquals(keyLength + "-bit decrypted inner attachment pdf should have same size as plain one",
                embeddedFilePriorToEncryption.length(), extractedEmbeddedFile.length());
View Full Code Here

            contentStream.setFont( font, 12 );
            contentStream.moveTextPositionByAmount( 100, 700 );
            contentStream.drawString( message );
            contentStream.endText();
            contentStream.close();
            doc.save( file );
        }
        finally
        {
            if( doc != null )
            {
View Full Code Here

            //then draw a red box in the lower left hand corner
            contentStream.setNonStrokingColor( Color.RED );
            contentStream.fillRect( 10, 10, 100, 100 );

            contentStream.close();
            doc.save( file );
        }
        finally
        {
            if( doc != null )
            {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.