pdftk flatten loses fillable field data












2















I'm trying to work out a solution to flatten PDFs with already-filled out fields on a Linux command line. I was messing around with GhostScript at first, but I found that tended to convert all the field data to garbage characters.



When I run this command



pdftk foo.pdf output bar.pdf flatten


and open bar.pdf in a PDF reader, it's flattened, but the data that was in the fields simply isn't present. The PDF is just the same as if it wasn't filled out, minus the fillable fields.



Is there something I'm missing here?



All the solutions I find on Google are about populating empty forms with .fdf files, which doesn't really pertain to my situation.










share|improve this question























  • I have the same issue. Can someone shed light on this? I have form elements on my source pdf. after flatten, my output has no values. version 2.02 on Ubuntu 12.04

    – fbas
    Nov 3 '16 at 11:54













  • it may be worth noting that my pdf file was modified by MacS Quartz in the Preview tool. This is how I filled in the PDF form fields. when I run this same source PDF through ghostscript, it works, but does note various issues and suggests that Quartz is to blame: **** This file had errors that were repaired or ignored. **** The file was produced by: **** >>>> Mac OS X 10.11.6 Quartz PDFContext <<<< **** Please notify the author of the software that produced this **** file that it does not conform to Adobe's published PDF **** specification.

    – fbas
    Nov 3 '16 at 12:35
















2















I'm trying to work out a solution to flatten PDFs with already-filled out fields on a Linux command line. I was messing around with GhostScript at first, but I found that tended to convert all the field data to garbage characters.



When I run this command



pdftk foo.pdf output bar.pdf flatten


and open bar.pdf in a PDF reader, it's flattened, but the data that was in the fields simply isn't present. The PDF is just the same as if it wasn't filled out, minus the fillable fields.



Is there something I'm missing here?



All the solutions I find on Google are about populating empty forms with .fdf files, which doesn't really pertain to my situation.










share|improve this question























  • I have the same issue. Can someone shed light on this? I have form elements on my source pdf. after flatten, my output has no values. version 2.02 on Ubuntu 12.04

    – fbas
    Nov 3 '16 at 11:54













  • it may be worth noting that my pdf file was modified by MacS Quartz in the Preview tool. This is how I filled in the PDF form fields. when I run this same source PDF through ghostscript, it works, but does note various issues and suggests that Quartz is to blame: **** This file had errors that were repaired or ignored. **** The file was produced by: **** >>>> Mac OS X 10.11.6 Quartz PDFContext <<<< **** Please notify the author of the software that produced this **** file that it does not conform to Adobe's published PDF **** specification.

    – fbas
    Nov 3 '16 at 12:35














2












2








2








I'm trying to work out a solution to flatten PDFs with already-filled out fields on a Linux command line. I was messing around with GhostScript at first, but I found that tended to convert all the field data to garbage characters.



When I run this command



pdftk foo.pdf output bar.pdf flatten


and open bar.pdf in a PDF reader, it's flattened, but the data that was in the fields simply isn't present. The PDF is just the same as if it wasn't filled out, minus the fillable fields.



Is there something I'm missing here?



All the solutions I find on Google are about populating empty forms with .fdf files, which doesn't really pertain to my situation.










share|improve this question














I'm trying to work out a solution to flatten PDFs with already-filled out fields on a Linux command line. I was messing around with GhostScript at first, but I found that tended to convert all the field data to garbage characters.



When I run this command



pdftk foo.pdf output bar.pdf flatten


and open bar.pdf in a PDF reader, it's flattened, but the data that was in the fields simply isn't present. The PDF is just the same as if it wasn't filled out, minus the fillable fields.



Is there something I'm missing here?



All the solutions I find on Google are about populating empty forms with .fdf files, which doesn't really pertain to my situation.







pdf pdftk






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 29 '16 at 22:13









Justin LardinoisJustin Lardinois

2081215




2081215













  • I have the same issue. Can someone shed light on this? I have form elements on my source pdf. after flatten, my output has no values. version 2.02 on Ubuntu 12.04

    – fbas
    Nov 3 '16 at 11:54













  • it may be worth noting that my pdf file was modified by MacS Quartz in the Preview tool. This is how I filled in the PDF form fields. when I run this same source PDF through ghostscript, it works, but does note various issues and suggests that Quartz is to blame: **** This file had errors that were repaired or ignored. **** The file was produced by: **** >>>> Mac OS X 10.11.6 Quartz PDFContext <<<< **** Please notify the author of the software that produced this **** file that it does not conform to Adobe's published PDF **** specification.

    – fbas
    Nov 3 '16 at 12:35



















  • I have the same issue. Can someone shed light on this? I have form elements on my source pdf. after flatten, my output has no values. version 2.02 on Ubuntu 12.04

    – fbas
    Nov 3 '16 at 11:54













  • it may be worth noting that my pdf file was modified by MacS Quartz in the Preview tool. This is how I filled in the PDF form fields. when I run this same source PDF through ghostscript, it works, but does note various issues and suggests that Quartz is to blame: **** This file had errors that were repaired or ignored. **** The file was produced by: **** >>>> Mac OS X 10.11.6 Quartz PDFContext <<<< **** Please notify the author of the software that produced this **** file that it does not conform to Adobe's published PDF **** specification.

    – fbas
    Nov 3 '16 at 12:35

















I have the same issue. Can someone shed light on this? I have form elements on my source pdf. after flatten, my output has no values. version 2.02 on Ubuntu 12.04

– fbas
Nov 3 '16 at 11:54







I have the same issue. Can someone shed light on this? I have form elements on my source pdf. after flatten, my output has no values. version 2.02 on Ubuntu 12.04

– fbas
Nov 3 '16 at 11:54















it may be worth noting that my pdf file was modified by MacS Quartz in the Preview tool. This is how I filled in the PDF form fields. when I run this same source PDF through ghostscript, it works, but does note various issues and suggests that Quartz is to blame: **** This file had errors that were repaired or ignored. **** The file was produced by: **** >>>> Mac OS X 10.11.6 Quartz PDFContext <<<< **** Please notify the author of the software that produced this **** file that it does not conform to Adobe's published PDF **** specification.

– fbas
Nov 3 '16 at 12:35





it may be worth noting that my pdf file was modified by MacS Quartz in the Preview tool. This is how I filled in the PDF form fields. when I run this same source PDF through ghostscript, it works, but does note various issues and suggests that Quartz is to blame: **** This file had errors that were repaired or ignored. **** The file was produced by: **** >>>> Mac OS X 10.11.6 Quartz PDFContext <<<< **** Please notify the author of the software that produced this **** file that it does not conform to Adobe's published PDF **** specification.

– fbas
Nov 3 '16 at 12:35










1 Answer
1






active

oldest

votes


















1














I was able to piece together this solution.



flattenpdf() {
if [[ $# -ne 2 ]]
then
echo "Usage: flattenpdf input.pdf output.pdf"
return 1
fi
temp=$(mktemp)
pdftk "$1" generate_fdf output ${temp}
pdftk "$1" fill_form ${temp} output "$2" flatten
rm ${temp}
}


It uses pdftk to generate an fdf file from the filled in pdf and then uses that file in a second run to flatten it. Why pdftk doesn't do something like this in the first place is beyond me.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1033264%2fpdftk-flatten-loses-fillable-field-data%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I was able to piece together this solution.



    flattenpdf() {
    if [[ $# -ne 2 ]]
    then
    echo "Usage: flattenpdf input.pdf output.pdf"
    return 1
    fi
    temp=$(mktemp)
    pdftk "$1" generate_fdf output ${temp}
    pdftk "$1" fill_form ${temp} output "$2" flatten
    rm ${temp}
    }


    It uses pdftk to generate an fdf file from the filled in pdf and then uses that file in a second run to flatten it. Why pdftk doesn't do something like this in the first place is beyond me.






    share|improve this answer




























      1














      I was able to piece together this solution.



      flattenpdf() {
      if [[ $# -ne 2 ]]
      then
      echo "Usage: flattenpdf input.pdf output.pdf"
      return 1
      fi
      temp=$(mktemp)
      pdftk "$1" generate_fdf output ${temp}
      pdftk "$1" fill_form ${temp} output "$2" flatten
      rm ${temp}
      }


      It uses pdftk to generate an fdf file from the filled in pdf and then uses that file in a second run to flatten it. Why pdftk doesn't do something like this in the first place is beyond me.






      share|improve this answer


























        1












        1








        1







        I was able to piece together this solution.



        flattenpdf() {
        if [[ $# -ne 2 ]]
        then
        echo "Usage: flattenpdf input.pdf output.pdf"
        return 1
        fi
        temp=$(mktemp)
        pdftk "$1" generate_fdf output ${temp}
        pdftk "$1" fill_form ${temp} output "$2" flatten
        rm ${temp}
        }


        It uses pdftk to generate an fdf file from the filled in pdf and then uses that file in a second run to flatten it. Why pdftk doesn't do something like this in the first place is beyond me.






        share|improve this answer













        I was able to piece together this solution.



        flattenpdf() {
        if [[ $# -ne 2 ]]
        then
        echo "Usage: flattenpdf input.pdf output.pdf"
        return 1
        fi
        temp=$(mktemp)
        pdftk "$1" generate_fdf output ${temp}
        pdftk "$1" fill_form ${temp} output "$2" flatten
        rm ${temp}
        }


        It uses pdftk to generate an fdf file from the filled in pdf and then uses that file in a second run to flatten it. Why pdftk doesn't do something like this in the first place is beyond me.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 2 '18 at 12:59









        Daniel LandauDaniel Landau

        1562




        1562






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1033264%2fpdftk-flatten-loses-fillable-field-data%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Plaza Victoria

            In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

            How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...