adobepdftk

pdftk, copying files without taking comments and annotations


I have many PDF files which contain comments and annotations made with Adobe Acrobat Reader. However, it will take many hours to copy these files with the comment being deleted manually.

Does PDFtk provide commands to copy files without taking comments and annotations?


Solution

  • One helpful solution is:

    $ LC_CTYPE=C && LANG=C
    $ pdftk in.pdf output - uncompress | sed '/^\/Annots/d' | pdftk - output out.pdf compress
    

    The out.pdf has no comments and annotations.

    Use bash to process on macOS:

    LC_CTYPE=C && LANG=C
    
    paperList=papers.txt
    rm ${paperList}
    ls | cat > ${paperList}
    
    saveDir=../temp_without_annon
    mkdir -p ${saveDir}
                                                                                                                                                                                                          130 ↵
    while IFS= read -r line
    do
        pdftk ${line} output - uncompress | sed '/^\/Annots/d' | pdftk - output  ${saveDir}/${line} compress;
    done < ${paperList}
    

    References