• Need help with ghostscript command syntax to compress pdf without flatt

    From Chandrashekhar Thalkar@21:1/5 to All on Mon Nov 21 06:46:20 2022
    I have PDF with form fields, I need to compress pdf but without flattening i.e. retain ability of fillable form fields after pdf compression.

    Following command is use to compress PDF file it compresses PDF file by 35% but pdf is flatterend i.e. in generated compress PDF does not have editable form fields

    gs -dSAFER -dBATCH -dNOPAUSE -dQUIET -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -sOutputFile=SAMPLE_compressed_via_gs.pdf SAMPLE.pdf

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ken@21:1/5 to All on Tue Nov 22 14:38:32 2022
    In article <3c149175-4095-43cd-9564-39e76d1311cdn@googlegroups.com>, cthalkar@nolo.com says...

    I have PDF with form fields, I need to compress pdf but without flattening i.e. retain ability of fillable form fields after pdf compression.

    Following command is use to compress PDF file it compresses PDF file by 35% but pdf is flatterend i.e. in generated compress PDF does not have editable form fields

    gs -dSAFER -dBATCH -dNOPAUSE -dQUIET -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -sOutputFile=SAMPLE_compressed_via_gs.pdf SAMPLE.pdf

    Ghostscript (more proerly Ghostscript's pdfwrite device) doesn't
    compress PDF files.

    If you are prepared to sacrifice quality, then it can reduce the file
    size, but the default settings do not do so (and you are using /PDFSETTINGS=/default, which is quite pointless since those are the
    defaults!)

    It is possible that the output PDF file may be smaller than the input
    file, but there is absolutely no guarantee that this is so, and it may
    equally well be larger. It all depends on how the input file is
    organised. For more details on the process see:

    https://ghostscript.readthedocs.io/en/latest/VectorDevices.html

    As to forms....

    There are two types of Forms in PDF; AcroForms and XML forms (XFA), you
    don't say which your PDF file is using, and you have not supplied an
    example to look at.

    Ghostscript and the pdfwrite device do not support XFA, at all. If your
    file contains XFA forms then the output file may look correct (probably
    won't) but it will no longer contain any XFA and will therefore no
    longer be a form.

    The PDF interpreter and pdfwrite device do not preserve the AcroForm and
    do not preserve Widget annotations as annotations. The *content* of the
    form is transferred, as marking objects on the page, so it will look the
    same. But there is no AcroForm in the output file, and so you can no
    longer edit the form fields.

    You can't do what you want using Ghostscript currently. That may change
    in the future, but I would not hold my breath waiting for it.


    Ken

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)