How to flatten the PDF generated using standard Appian 'PDF Doc From Template' smartservice (under Document generation)?

How to flatten the PDF generated using standard Appian 'PDF Doc From Template' smartservice (under Document generation)?

I am using a PDF Template(fillable PDF form created using Foxit Phantom) with some form fields, whose values are dynamically filled by Appian. It works perfectly. However the generated PDF is editable - a user can change the values. Would like to prevent the user from making changes, so want to the PDF.

I tried to use the plug-in 'Fill PDF'. It does have the option to flatten. However in the process design, I am not able to add the PDF form fields and set their corresponding values dynamically. The documentation on this plug-in doesn't address this in detail. Anyone faced this issue before and could help?

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    I'm not aware of an option to do this with the OOTB service. Definitely not ideal, but could you potentially run the Appian service, THEN run the Fill PDF service (or maybe even one of the other services - I haven't gone through all of the code in awhile to know offhand which ones call the flatten method on completion)?

    Alternatively, a few other ideas (none of them great, admittedly): a new service to flatten in PDF could be built or you could look at generating a dynamic Word document and then convert that to PDF which would lock it down.

    In any case, improving the Appian smart service to support a flattening option sounds like an enhancement request that should be submitted to Appian Support.
  • I've run into this issue as well.

    The Fill PDF plugin has a lot of limitations, as does the PDF from Template smart service. I think that, provided you don't mind the extra server load, would be to use the PDF from Template smart service, output the new document into a PV, and pass that immediately into a Fill PDF plugin in order to flatten it. As I mentioned, the only issue would be the added server load due to creating double the documents without the ability to delete them in-process.

    Would love for Appian to add the ability to flatten within the smart service- which has much more documentation and information available online.

    Cheers!

  • 0
    Certified Lead Developer

    Hi jamesg,

    I understand this is 11 months late, but I found two solutions to your issue. 

    The first is the one I'm currently using and the simpler one - mark the form fields as Read Only in Adobe.

    Then, the OOTB PDF Doc From Template smart service can still populate the form fields, but the final PDF will no longer be editable. 

    The second is to use the Fill PDF plugin (part of PDF tools). You can add the form fields when you populate the PDF Fields data input by passing in an array of dictionary like so:

    {

    {name = "formField1", value = "value1"},

    {name = "formField2", value = "value2"},

    etc.

    }

    This solution should work as well - you'll have to manually set up the names of the fields yourself though, the smart service can't parse that automatically.