Syntax Highlighter JS

Friday, July 27, 2012

Downloading Visual Force pages that are rendered to PDF - Part 3

The first and second post in this series were targeted to sales force developers.  Since they contain enough code to get your project going, I decided to focus this third post on what the button click admin would want.

So what is that? I think it is any easy tool to automate these tasks:
  • Select records with the power of SOQL.
  • Download attachments on these records by file name search.
  • Where possible convert these files to PDF (using the free open office).
  • Download apex pages already rendered as PDF to local PDF file for each record.
  • Combine these files for each record into one pdf "packet".
  • Combine each packet into a master PDF for easy printing.
 With the caveats that this is a free, unsupported, and closed source tool that will only download one apex page per record (and that page must use the ?id= syntax from the standard controller), here is such a tool.  It uses the partner WSDL so it should work out of the box for most salesforce instances.

Please note that this is a rough draft and as such, I full expect bad / incomplete settings will result in errors. Also, please note that it requires a JRE and Open office to run.

Here is a screen shot of the main application:

Please note that you will have to exit and restart after saving your initial preset.  These and other bugs will be fixed in a future build.

In the next post, I will explain the settings in greater detail and have a demo video.

Important setting notes:
  • Your SOQL statement must be valid - be sure to test it in something like explorer
  • This version only works on the opportunity object
  • You MUST select both the ID and the Account Name
  • You can specify an Order By Clause but if you specify more than one, the first one will be used to group the results in to sub-folders (i.e. by division) 
  • You only need to include the apex page name and the ?id= for the page url, the rest will be built for you.
  • The search file names need to be comma delimited
  • If you combine files and get an apex page, the apex page will be the first in the pdf packet generated.  Otherwise files will be in the order of searching.
Here is an example of some working settings: