Hi all, I am very new to xsl-fop and to the world of xml and xsl. I am currently working on creating dynamic pdf using coldfusion mx and FOP. I am using Nate Nelson's tutorial published in ColdFusion Dev Journal. Everything is working great, except I want to embed couple of fonts into my pdf, and they are all generated real time. I have transformed the .pfm files to .xml based on a tutorial found online. And I made changed to the userconfig.xml file as well. Now I cannot figure out who to include the userconfig.xml file into all the pdf that will be created. Here is the code that I am using to create my pdfs. ----------------------------------------- <CFSET MyStylesheet = "style.xsl"> <cfset pdfFile = "Result.pdf"> <cfset MyXml = "Output.xml">
<!--- get contents of xml file and xsl file ---> <!--- <CFFILE ACTION="READ" FILE="#expandpath(MyXml)#" VARIABLE="XMLFileContent"> ---> <CFFILE ACTION="READ" FILE="#expandpath(MyStylesheet)#" VARIABLE="XSLFileContent"> <!--- perform xml transformation with XMLFileContent agaisnt XSLFileContent ---> <CFSET TransformedXmlCode = XmlTransform(proposal, XSLFileContent)> <!--- now invoke the FOP component - pass in transformed xml and pdf file to be created ---> <cfinvoke component="FOP" method="ConvertStringToPDF" foString="#TransformedXMLCode#" returnvariable="FOPByteArray"> <!--- No display PDF file to browser ---> <cfscript> //Retrieve the page context's response object context = getPageContext(); context.setFlushOutput(false); response = context.getResponse().getResponse(); out = response.getOutputStream(); //Set the MIME type response.setContentType("application/pdf"); //We must specify the content length but that's easy using the //ByteArrayOutputStream's size method response.setContentLength(FOPByteArray.size()); //Write the output to the browser and flush (to actually send) out.write(FOPByteArray.toByteArray()); out.flush(); //Close the output stream object out.close(); </cfscript> ------------------------------------------ and here is the fop.cfc file ----------------------------------------- <cfcomponent> <!--- Initialize the FOP driver from xml.apache.org ---> <cfset variables.driver = CreateObject("java", "org.apache.fop.apps.Driver")> <cfset variables.lockname = CreateUUID()> <cffunction name="ConvertFileToPDF" access="public"> <cfargument name="foFile" type="string" required="true"> <cfset var output = "" /> <!--- Set up Java input source ---> <cfset var input = CreateObject("java", "org.xml.sax.InputSource")> <cfset input.init( ARGUMENTS.foFile)> <!--- Proceed with PDF generation ---> <cfset output = private_generatePDF(input)> <cfreturn output /> </cffunction> <cffunction name="ConvertStringToPDF" access="public"> <cfargument name="foString" type="string" required="true"> <!--- Set up Java input source ---> <cfset var reader = CreateObject("java", "java.io.StringReader")> <cfset var input = CreateObject("java", "org.xml.sax.InputSource")> <cfset reader.init(foString)> <cfset input.init(reader)> <!--- Proceed with PDF generation ---> <cfset output = private_generatePDF(input)> <cfreturn output /> </cffunction> <cffunction name="private_generatePDF" access="private"> <cfargument name="input" type="any" required="true"> <!--- Output stream for writing PDF file ---> <cfset var output = CreateObject("java", "java.io.ByteArrayOutputStream")> <!--- Turn on the output stream ---> <cfset output.init()> <!--- Hook the FOP driver to the input/output ---> <cfset variables.driver.setInputSource(input)> <cfset variables.driver.setOutputStream(output)> <!--- Perform the actual PDF generation ---> <cfset variables.driver.run()> <cfreturn output /> </cffunction> </cfcomponent> -------------------------------- you can also take a look it at http://photos.sys-con.com/story/res/45575/source.html --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]