Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Getting the pdf form from a task id

Avatar

Former Community Member

I am writing a component for getting the pdf form from a task id, I know how to get the form data(xml) from the task but how can I know which form template to use to render the it as pdf form?

7 Replies

Avatar

Former Community Member

Anyone know how to get the form template from a task, so I can render it as a PDF form?

Avatar

Former Community Member

I still can't find an answer yet, please advise if it's possible to get the form template from a task?

Avatar

Level 10

You can do that!

Use the following method to get the XML data along with the Form Template:

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData)

The above method returns a Form Instance which consists of both Form Template and XML data (only if your thrid parameter is true)

If you would like to find the template path, you can use:

 FormInstanceVariable.getTemplatePath(); 

which returns a template path string.

Here is API reference.

Nith

Avatar

Former Community Member

Thanks Nith.

so if I use

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData)

and set the retrieveData to true, it will return a PDF?

Avatar

Level 10

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData).getDocument();

The above code will return the PDF document.

Or if you want the XML data & template path separatelly, use the following expressions:

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData).getXFAData();

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData).getTemplatePath();

Nith

Avatar

Level 10

Sorry, a small mistake on my previous response..

The following code will return XML data and not the actual PDF! You will have to import it to the template to get the PDF result.

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData).getDocument();

Nith