Question

Generation of Word doc without manual interaction

Hi,

I have a requirement to generate Word document and same to be attach to Work object.
As i gone through PDN, followed procedure avialble in below path:
https://pdn.pega.com/sites/pdn.pega.com/files/help_v722/procomhelpmain.htm#howto/howto2/howtosupportwordmerge.htm

But, the problem is we have to click on the button (Create Merge Document) to generate word document.

I need to create the word document automatically with activity rule only.

Please suggest any approach.

Thanks

Anupama P

***Updated by moderator: Lochan to add Categories***

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Comments

Keep up to date on this post and subscribe to comments

June 7, 2017 - 12:10pm

I suggest you trace to find out what activities the button invokes, and then code your activity to invoke some of the same ones.

 

 

June 8, 2017 - 2:01am
Response to ericosman_GCS

Hi Ericosman,

Thanks for your suggestion. I have traced the button activities, button is displaying through non-auto generated HTML(section).

On click of button, Java script functions are running. I have to invoke those functions into activity.

So, is there any possibility to call Java Script/HTML code from an activity..? Please suggest.

 

Pega
June 7, 2017 - 1:44pm

There are several approaches that you can use to generate WORD (and other Microsoft Office) documents with PRPC.

The PDN article you provided does this clientside - it uses Microsoft Silverlight and Microsoft APIs to create (actually modify) WORD documents on the Windows platform.

If you need to produce WORD files on the serverside  (which is a Java environment; and may be running on Windows or Linux) - you have a few choices:

1. Use the Apache POI library (which is shipped with PRPC) from a PRPC Activity (etc).

2. Generate a single XML document that adheres to the (older) Microsoft Office XML Format.

3. Generate a 'compound' (zipped up XML files essentially) Document that is based on the (newer) Open Office XML format.

4. You could also use Pega Robotics as well - but I don't have enough experience on how to advise how you would do that exactly.

Option #1 is quite straightforward - you can pretty much follow the Apache POI examples - remembering that in PRPC Activities you will have to fully qualify Java classnames etc (there is no 'import' mechanism for Activities) - but it might not be suitable if you have a lot of formatting to do. (Or you could consider using a 'Template' Document which you modify I guess for this).

Option #2 works very well for simple small documents; it is pretty easy to map PRPC properties using a XML Stream Rule (you are basically just creating an XML document using this method) - but it doesn't scale as well for larger / complex documents. (The XML 2003 format is quite 'bloated' - but has the advantage of being a single document).

Option #3 requires more complex processing - since you have to construct several XML documents and then zip them up.