prabudass has asked for the wisdom of the Perl Monks concerning the following question:

I extracted all pages from pdf file using "PDF::Extract". If i open that extracted pdf file it open correctly. But if i try to close that pdf file, it asked "Do you want save changes dialog box". Could you please explain how to rectify this problem.

Code:
use PDF::Extract;
$pdf=new PDF::Extract( PDFDoc=>"C:\\sample.pdf");
$i=1;
$i++ while ( $pdf->savePDFExtract( PDFPages=>$i ) );

Thanks,
Prabudass

Replies are listed 'Best First'.
Re: How to do in "PDF::Extract"? (Acrobat auto repairing?)
by almut (Canon) on Dec 18, 2008 at 12:14 UTC

    This could be a side effect of Acrobat doing some "auto repair" upon reading in the file  (also see Unexpected & Unnecessary Popup "do you want to save changes to 'x' before closing ?").  What is triggering the auto repair has yet to be found out, though...

    If you accept to save changes and then compare the newly saved version with the original one, are there any differences?  (use a tool to compare binary files, such as "cmp -bl ..." on Unix)

    Update: for testing purposes, you could try to (dummy-)process the PDF file created via PDF::Extract using some other tool, e.g. the already mentioned "pdf tool kit":

    $ pdftk original.pdf output fixed.pdf

    This would fix anything that pdftk considers worth fixing...  Then check whether Acrobat is still exhibiting the undesired behavior when using this fixed.pdf.

    BTW, you could also use pdftk directly to extract all pages:

    $ pdftk sample.pdf burst

    As hda said, an excellent tool — highly recommended!

      This could be a side effect of Acrobat doing some "auto repair" upon reading in the file...

      Having tried PDF::Extract on some randomly selected pdf files, I find that its output is badly broken -- in particular, the 'xref' table is a mess.

      When Adobe Acrobat (Professional 8.1.2) read the output of PDF::Extract (which it wasn't always prepared to do) it would offer to save changes on close -- and the result was a cleaned up file.

Re: How to do in "PDF::Extract"?
by hda (Chaplain) on Dec 18, 2008 at 12:13 UTC
    Hi!

    There is an excellent tool called "PDFTK" (the pdf tool kit).
    You will find it here:

    http://www.pdfhacks.com/pdftk

    It is also well documented, easy to use and can be called via "system".

    Hope this helps!
Re: How to do in "PDF::Extract"?
by matze77 (Friar) on Dec 18, 2008 at 10:25 UTC


    savePDFExtract

    $pdf->savePDFExtract(PDFPages=>"1 3-6",
    PDFDoc=>'C:/my.pdf', PDFCache=>"C:/myCache" );

    If there is an error then an error page will be served and savePDFExtract will return a "0". Otherwise savePDFExtract will return "1" and the saved PDF location and file name will be "C:/myCache/my1_3..5.pdf".
    Full Text:
    http://search.cpan.org/~nsharrock/PDF-Extract-3.03/Extract.pm#savePDFExtract

    Hmm? Where is the error?
    MH
      As per your advice, i modified that code. No error found but my problem not solved. I opened the extracted output pdf file and then without any modification i closed it. It shows the Acrobat dialog window "Do you want to save changes to "my1.pdf" before closing?". Could you please help me.

      Thanks,
      Prabudass

        If i understand it right (and others suggested), this window comes from Acrobat so there is maybe no opportunity to control this window with your perl code, maybe you could tune Acrobat to "autosave" or something, but i dont own Acrobat ...

        MH
        Try Ghostview/SumatraPDF/Foxit/Inkscape instead.
        Try This Code. it will help for you. Hope
        $pdfextract=new PDF::Extract(PDFDoc=>"input path with pdf file"); $i=1; while($pdfextract->savePDFExtract(PDFPages=>$i,PDFCache=>" destination +path")) { $i++; + }
        This code work for me Fine...
Re: How to do in "PDF::Extract"?
by moritz (Cardinal) on Dec 18, 2008 at 10:20 UTC
    If i open that extracted pdf file it open correctly

    How do you open it? Which program do you use?

    if i try to close that pdf file, it asked "Do you want save changes dialog box".

    That sounds more like a problem of whatever PDF editor you use than with your Perl program.

      I opened the extracted pdf file manually through acrobat 8 professional.
      Please explain how to save that extracted pdf file through pdf::extract module.

      Thanks,
      Prabudass.
Re: How to do in "PDF::Extract"?
by Anonymous Monk on Dec 18, 2008 at 10:12 UTC
    There is no problem.