Source Avalible: inline
Project Page: n/a
Description
This solution was initially created for the Royal Australasian College of Surgeons. They have a few application processes that involve filling out forms that are several pages long that require scanned documents to be uploaded to validate their answers. Once the application is completed, one single document needs to be email to the appropriate person. The solution is to create a pdf from a Crystal report for the answers typed in, and then merge this pdf with the scanned documents that were uploaded. To facilitate this process, two wrapper dll’s were created which used Crystal Reports runtime (version 9 or 10) and a 3rd party tool for merging pdf’s.
- ASICrystalPdf.Maker
- RACSpdf.Merger
The code to create a pdf from the Crystal Report is quite simple, just CFOBJECT the wrapper dll, and then use the CrystalPDF method to create the pdf. This could be used to create pdf’s of members’ account or profile. These pdf’s could be created real time. The last line is a CFCONTENT tag – this will allow the pdf which is not saved on a path that can be accessed directly from a web browser to appear on the member’s browser. This ensures that pdf’s created and viewed online are secure and can only be viewed by the logged in member.
<cfsetting enablecfoutputonly="yes">
<!----------------------------------------------------
Copyright © 2005 Advanced Solutions Inc. All rights reserved.
TEMPLATE: pdfMaker.cfm
DESCRIPTION: Print Crystal Report v9 or v10 to pdf and allow view/download
Requires Crystal Reports Developement or Runtime v9 or v10 on web server
Requires asiCrystalPdfMaker.dll registered on web server
Uses cfcontent, so the crystal report and pdf's do not have to be on any web
path for even greater security
Parameters:
1 - Location of crystal report
2 - ODBC DSN
3 - SQL Login
4 - SQL Password
5 - Location to export pdf
6 - 1st Crystal Report Parameter, such as iMIS ID, Chapter, State, etc.
7 - 2nd Crystal Report Parameter
8 - 3rd Crystal Report Parameter
9 - 4th Crystal Report Parameter
10 - 5th Crystal Report Parameter
11 - 6th Crystal Report Parameter
12 - 7th Crystal Report Parameter
13 - 8th Crystal Report Parameter
14 - 9th Crystal Report Parameter
15 - 10th Crystal Report Parameter
The Crystal Report parameters must be empty string "" if not defined or empty.
ColdFusion COM interface can't handle optional parameters
MODIFICATION HISTORY:
DATE USER ACTION
2 Dec 2005 S.Moseley Created
---------------------------------------------------->
<cfobject action = "Create"
type = "COM"
class = "ASICrystalPdf.Maker"
name = "anotherStephenMoseleyWrapper">
<cfset anotherStephenMoseleyWrapper.CrystalPDF("e:\SSTA\SSTA.rpt", "iMISeCM", "rptuser", "crystal","e:\SSTA\test.pdf", "141438", "GS", "","","","","","","","")>
<cfcontent type="application/pdf" file="e:\SSTA\test.pdf">
The second wrapper dll is to merge pdf’s. This includes putting a title and description on the top of each page, and giving them a page x of y on the top of each page. CFOBJECT the wrapper dll for merging pdfs. Start with the initial pdf, then merge jpegs, pdfs and tiffs. The Addjpg method allows for many other types of images to be merged, such as gif and bmp. It will size all images to 1 page. The adding of pdfs and tiffs includes how many pages to merge. For instance you can specify only to merge the 1st page of the uploaded document. Finally save the merged pdf to disk.
<cfobject action = "Create"
type = "COM"
class = "RACSpdf.Merger"
name = "pdfMerger">
<cfset pdfMerger.StartRequest("#destination#\temp.pdf")>
<cfset pdfMerger.Addjpg("#destination#\Attachments\#TORFA.FileName1#")>
<cfset pdfMerger.addPDF("#destination#\Attachments\#TORFA.FileName2#","-1")>
<cfset pdfMerger.AddTIF("#destination#\Attachments\#TORFA.FileName3#","-1")>
<cfset pdfMerger.SaveToDisk("#destination#\#l_SaveName#")>
As you can see, the number of lines of ColdFusion code to perform such tasks is quite minimal. The Crystal reports pdf maker is very robust, and cuts down on incompatibility between the Crystal reports ActiveX and Java viewers by saving it to a highly compatible pdf format. The security of these pdf’s can be easily coded, and pdf’s do not need to be browse-able. Merging of pdf’s could be used to merge several of these dynamic reports, one that changers per member ID, and a report that is the same for all members. The possible usages are limitless.