Hi,
I attempted to turn a svg file directly into a pdf file with Railo (3.1.x on windows).
Getting close... but not sure why we got the "
railo.runtime.exp.NativeException: can't find Format of given image
"
error.
Thoughts? Many thanks.
<!--
(1) read the svg file in binary
FileReadBinary
-->
<cfscript>
svgfile = FileReadBinary("#ExpandPath('..\svgFiles')#\123.svg");
file = toBase64(svgfile);
</cfscript>
<!---
<cfdump var="#svgfile#">
<CFABORT>
--->
<!--
(2)
invoke the CFC
svg2PDF.cfc?method=make&pdfBody=''
-->
<cfinvoke
webservice = "
http://myserver/convert2pdf.cfc?wsdl"
method = "make"
pdfBody ="#file#"
pdfName = "test1.pdf"
returnVariable = "output">
</cfinvoke>
<!--- convert file binary stream to png and then pdf CFC --->
<cfcomponent>
<cffunction name="make" access="remote" returnformat="json" returntype="any" output="true">
<cfargument name="pdfBody" type="any" required="true" />
<cfargument name="pdfName" type="string" required="false" />
<cfset request.acceptExt = 'image/jpeg,image/gif,image/png' />
<!--- read the base 64 representation of the image --->
<cfset cfImageObject = ImageReadBase64(pdfBody) />
<!--- create a new cf image object --->
<!--- original, without format
<cfimage source="#cfImageObject#" destination="aPng.png" action="write" overwrite="yes">
--->
<cfimage source="#cfImageObject#" destination="aPng.png" format="PNG" action="write" overwrite="yes">
<cfdocument format="pdf" overwrite="yes" filename="#aPDF.pdf" localurl="true">
<!---
<cfdocument format="pdf" overwrite="yes" filename="#arguments.pdfName#" localurl="true">
--->
<cfdocumentitem type="header">the header</cfdocumentitem>
<cfdocumentitem type="footer">the footer</cfdocumentitem>
<cfdocumentsection>
<cfoutput>
<!--- it works! --->
<img src="aPng.png" />
</cfoutput>
</cfdocumentsection>
</cfdocument>
<!---
<cfreturn SerializeJSON(form) />
--->
</cffunction>
</cfcomponent>