Extract PDF from Mac's *.pages files for windows/linux users

Help
AliBy
2013-02-04
2016-05-07
  • AliBy

    AliBy - 2013-02-04

    I am wanting to have a script that will extract the preview PDF from "*.pages" so that those on Windows and Linux can effectively view the contents. I have got the following bat file to work:

    7z e "Myfile_1.pages" -ir!"QuickLook\Preview.pdf"
    RENAME "Preview.pdf" "MyFile_1.pdf"

    I am not sure how to make a more intelligent script that will effectively loop through all the *.pages files in the directory and run the extraction/rename for each. Can someone advise?

     
  • fernando

    fernando - 2013-02-04

    For every ".pages" file in the current directory, you want to extract the "QuickLook\Preview.pdf" file to the current directory, and rename the "Preview.pdf" file to the name of the ".pages" file from which it was extracted?

    In a batch script, run from the current directory, try...

    FOR %%A IN (*.pages) DO (
    7z e "%%A -ir!"QuickLook\Preview.pdf"
    RENAME "Preview.pdf" "%~nA.pdf"
    )

     
  • AliBy

    AliBy - 2013-02-04

    Perfect, it works great.

    I had to check that there are only "new" .pages files there. If there are it extracts the preview pdf and then cannot rename it due the duplicate name. Then the newly created preview.pdf file causes the rest of the process to bomb out because of the existing file.

     
  • AliBy

    AliBy - 2013-02-04

    OK I tried to add a "check" in the loop that added a list of which files were skipped:

    for %%A in (*.pages) do (

            if exist "%%~nA.pdf" (
              echo "%%~nA" >> skipped.txt
            )
    
            if not exist "%%~nA.pdf" (
              7z e "%%~nA.pages" -ir!"QuickLook\Preview.pdf"
              RENAME "Preview.pdf" "%%~nA.pdf"
            )
    
    )
    

    There may be better ways of doing it, but it seems to work OK.

     
    Last edit: AliBy 2013-02-04
  • fernando

    fernando - 2013-02-05
    FOR %%A IN (*.pages) DO (
    IF NOT EXIST "%%~nA.pdf" (
    7z e "%%A" -ir^^!"*QuickLook\Preview.pdf"
    RENAME "Preview.pdf" "%%~nA.pdf"
    ) ELSE (
    >>skipped.txt ECHO.%%~nA
    )
    )
    
     
  • abbylee

    abbylee - 2015-08-28

    Thank you, fernando
    I have similar request to find a script that can extract PDF pages. But I only find C# PDF page extraction sample code.
    Thank you for sharing your experience, it's of great help to my work.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks