Archive for December 17th, 2007

Enabling Acrobat Shared Review using ColdFusion

Monday, December 17th, 2007

The PDF annotations in Acrobat are impressive, but the implementation was much more suited to an Intranet rather than an Internet environment. In Acrobat 8, Adobe introduced a new type of online annotation for PDFs, called a ‘Shared Review’. In a shared review the information for configuring the annotation store is on the PDF itself, which makes it much more flexible and robust than previously.

Shared Reviews are normally initialed by a user from within Acrobat. The user follows a wizard, which adds some JavaScript to the PDF. To enable a Shared Review programmatically, needs a suitable library.

ColdFusion8 has a lot of new PDF related functionality provided by the new <cfpdf> tags. Adding JavaScript isn’t one of them. JavaScript can be added, however, by using the iText library, which is included in ColdFusion, presumably to help implement the CFDocument functionality.

The JavaScript that you need to insert into the PDF can be copiedĀ  from an existing PDF made using the manual approach, and then tweaked to suit your requirements.

Here is a snipped showing how to insert the JavaScript using the iText PdfStamper class.

<CFSCRIPT> 
    reader = CreateObject("java", "com.lowagie.text.pdf.PdfReader") 
	.init(expandPath("#ipFName#"); 
    opFile = CreateObject("java", "java.io.FileOutputStream") 
	.init(expandPath("#opFName#")); 
    stamper =CreateObject("java", "com.lowagie.text.pdf.PdfStamper") 
	.init(reader,opFile); 
    stamper.addJavascript(#jscript#); 
    stamper.close(); 
</CFSCRIPT>