svg to pdf problem with Railo 3.1.x

Skip to first unread message

Oct 2, 2015, 4:21:25 PM10/2/15
to Railo

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

Thoughts?  Many thanks.

(1) read the svg file in binary
    svgfile = FileReadBinary("#ExpandPath('..\svgFiles')#\123.svg");
    file = toBase64(svgfile);

<cfdump var="#svgfile#">

invoke the CFC

    webservice = "http://myserver/convert2pdf.cfc?wsdl"
    method = "make"
    pdfBody ="#file#"
    pdfName = "test1.pdf"
    returnVariable = "output">

<!--- convert file binary stream to png and then pdf CFC --->
    <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>
                    <!--- it works! --->
                    <img src="aPng.png" />

        <cfreturn SerializeJSON(form) />

Adrian Lynch

Oct 4, 2015, 3:34:49 PM10/4/15
Not really what you want to hear, but why don't you try it on a more up to date version of Railo, or better still, Lucee?

Just download the Express version.


Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at
You received this message because you are subscribed to the Google Groups "Railo" group.
To view this discussion on the web visit
For more options, visit

Reply all
Reply to author
0 new messages