"OutPath" a valid path?  Yes

What have you done before? This exact code works with 0.8.0-incubating, but not with 1.1.0.

I can send it to you directly, but I do not want to post the complete code to this mailing list.

Did you create a new pdf or manipulate an existing one or ...?

  I am creating a new PDF by copying pages from an existing PDF.

More of the code fragment:

       PDDocument InputDoc = null;
       PDDocument OutputDoc = null;
       PDDocument DrawingDoc = null;
       String OutPath = "";
. . . . .
       for (File InFile : PdfFileList)
       {
           try
           {
               InputDoc = PDDocument.load(InFile);
               InFileName = InFile.getName();
               InDirName = getDirName(InFile.getPath());
. . . . .
               // Create output PDF document
               OutputDoc = new PDDocument();

               // Get a list of pages from the input PDF document
               List pages = InputDoc.getDocumentCatalog().getAllPages();
               // Process each page
               int i = 0;
               for (Object obj : pages)
               {
                   String Barcode = null;
                   i++;
                   PDPage page = (PDPage)obj;
. . . . .
                       copyPage(OutputDoc, page);
               }
           }
           catch (Exception e)
           {
               e.printStackTrace();
           }
           finally
           {
               try
               {
                   // Save and close the output file
                   if (OutputDoc != null)
                   {
                       OutputDoc.save(OutPath);
                       OutputDoc.close();
                   }
                  // Save and close the input file
                   if( InputDoc != null )
                       InputDoc.close();
                   if( DrawingDoc != null )
                       DrawingDoc.close();
               }
               catch (Exception e)
               {
                   e.printStackTrace();
               }
           }
       }

--------------------------------------------------
From: "Andreas Lehmkuehler" <[email protected]>
Sent: Sunday, April 11, 2010 4:13 PM
To: <[email protected]>
Subject: Re: Problem Moving to version 1.1.0

Hi,

Alan Thomas schrieb:
Sorry . . . That was just a warning --- here is the exception:

java.io.IOException: The handle is invalid
       at java.io.RandomAccessFile.seek(Native Method)
at org.apache.pdfbox.io.RandomAccessFile.seek(RandomAccessFile.java:59) at org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:96) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
       at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
       at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:925)
       at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:201)
       at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:206)
at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:430) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:361) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:767)
       at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:372)
at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1082)
       at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:899)
       at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:880)
at autoinsertpdf.AutoInsertPDF.InsertDrawings(AutoInsertPDF.java:295)
       at autoinsertpdf.AutoInsertPDF.main(AutoInsertPDF.java:60)

Here is where it occurs:

PDDocument OutputDoc;
. . . . .
// Save and close the output file
if (OutputDoc != null)
{
  OutputDoc.save(OutPath);    <--- Exception occurs here
  OutputDoc.close();
}
Hmm, is "OutPath" a valid path? What have you done before? Did you create a new pdf or manipulate an existing one or ...?

BR
Andreas Lehmkühler

Reply via email to