Script: PDF Transformation

341 views
Skip to first unread message

somesh.m...@gmail.com

unread,
Sep 3, 2013, 5:40:31 PM9/3/13
to suppor...@runmyprocess.com, somesh. mukherjee
Hi,

Is there a way to overwrite the previously created file instead of creating a new one, whenever the PDF transformation is executed? I am trying to hold on to the original file id, which in my use case is shared with certain sub-processes spawned from the parent process, when the sub-processes are initiated by the parent.

Any flexibility to overwrite the content of a file in the RMP file world with updated content from a second file would suffice.

Also, I have noticed that the created files through PDF transformation have restricted access. We have public users as well, so is there a way to alter the accessibility of a file resource once it is created?

Thanks!

thoshino

unread,
Sep 3, 2013, 6:35:57 PM9/3/13
to suppor...@runmyprocess.com, somesh. mukherjee, somesh.m...@gmail.com
Hi Somesh,

It is not possible to overwrite the file when creating a PDF file. 
RMP Freemarker functions (https://sites.google.com/a/runmyprocess.com/user-guide-runmyprocess/HOWTO-USE-FREEMARKER) provide various controls to create/copy/modify/overwrite files but it only works for text based file formats (txt, csv, xml, html...), not binary files.

But, in your case, I worry that overwriting files is NOT your best approach. 
File id's are shared among all process instances, so if you overwrite it it might cause error. 
e.g. while the child process is treating PDF, another parent process might start which will overwrite the PDF file.

Maybe deleting the file at the very end of your child process might work for you? This way your File storage will only contain files that are being processed, will not overflow with useless data.
To delete, you can use Freemarker function:
${delete_file("your-file-id")}
Of course in above case, you need to pass the file id from parent process to child process, you can do this in Input variable.

Also, you can change a file's access configuration using Freemarker function:
${save_file_desc("your-file-id",{"visibility":"PUBLIC"})}

Best regards,

Taka
Message has been deleted

somesh.m...@gmail.com

unread,
Sep 3, 2013, 8:26:34 PM9/3/13
to suppor...@runmyprocess.com, somesh. mukherjee, somesh.m...@gmail.com
Thanks Taka! There is a need to keep the pdf updated in my functional scenario.

This is my use case: We have an awards nomination process (parent process). After the nominator has completed filling up the nomination and submitted the form, the references (provided in the nomination) receive notification requests (child processes) to log into the system and provide endorsements for the nominee. On the reference form, there is a link to view the Nomination details in PDF mode.

The catch: Parent process (nomination process) stays open for 2 years and the nominator can return to it at any time and adjust the nomination data. Hence, there is a need to refresh the Nomination PDF every time there is an update, so that when the Reference tries to view the Nomination details on the PDF, he sees the latest data.

Please let me know your thoughts. I designed the flow to create the nomination PDF, from the nomination process level data when the nominator submits the form. When spawning the reference requests, I intend to pass the PDF file id to the reference processes (child).

Thanks!

thoshino

unread,
Sep 3, 2013, 8:55:18 PM9/3/13
to suppor...@runmyprocess.com, somesh. mukherjee, somesh.m...@gmail.com
In that case, you can re-create pdf every time there is an update, and make the web interface refer to the newest version of pdf.

The basic direction you draw is good and valid.
The new file id (or url) will be saved in a collection object specific for that parent process (= 1 record per 1 nomination). The record id of collection will be passed to child process from parent.
Then in your web interface, you can make an empty HTML widget, configure an ID for this widget, and have a Javascript widget that will update the HTML content for that.

The function to set the HTML content will look like,
id_of_html_widget.setHtml("<a href='url_from_collection_object' target='_blank'>Link to PDF</a>")

You will put this in the ok call back for the Javascript function to read from collections,
id_collection.listCallback(pattern,options,callbackSuccess,callbackFailure)

This way, every time the web interface is loaded (reference opens the browser), the javascript will run which will read from collection the newest file url, and show a URL link to that pdf.

I hope I understood your case correctly. Does this sound fit with your requirement?

Best regards,

Taka

somesh.m...@gmail.com

unread,
Sep 3, 2013, 9:11:58 PM9/3/13
to suppor...@runmyprocess.com, somesh. mukherjee, somesh.m...@gmail.com
Thanks Taka! I thought about the collections to share the File ID between the parent and the child processes, but was willing to avoid using one if there was any other feasible approach.

Thank you for helping here and for providing your suggestions!

Reply all
Reply to author
Forward
0 new messages