Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-54

please correct the SetField example

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 1.8.5, 1.8.6, 2.0.0
    • 1.8.6, 2.0.0
    • Writing
    • None

    Description

      [imported from SourceForge]
      http://sourceforge.net/tracker/index.php?group_id=78314&atid=552832&aid=1182270
      Originally submitted by nobody on 2005-04-13 07:51.

      Hi, at last I understand what is wrong with
      org.pdfbox.examples.fdf.setField example - my file is
      encripted but there wasn't code for decryption please
      add it there for the other developers.
      Ilya

      private void setField( String[] args ) throws
      IOException, COSVisitorException
      {
      PDDocument pdf = null;
      try
      {
      if( args.length != 3 )

      { usage(); }

      else
      {
      SetField example = new SetField();

      pdf = PDDocument.load( args[0] );
      PrintFields exporter = new PrintFields();
      if( pdf.isEncrypted() )
      {
      try

      { pdf.decrypt( "" ); }

      catch ( CryptographyException e )

      { System.err.println( "Error: The document is encrypted." ); usage(); }

      catch( InvalidPasswordException e )

      { System.err.println( "Error: The document is encrypted." ); usage(); }

      }
      example.setField( pdf, args[1], args[2] );
      pdf.save( args[0] );
      }
      }
      finally
      {
      if( pdf != null )

      { pdf.close(); }

      }
      }

      Attachments

        Activity

          People

            tilman Tilman Hausherr
            Anonymous Anonymous
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: