svg to pdf problem with Railo 3.1.x

30 views
Skip to first unread message

lovera...@gmail.com

unread,
Oct 2, 2015, 4:21:25 PM10/2/15
to Railo
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>


Adrian Lynch

unread,
Oct 4, 2015, 3:34:49 PM10/4/15
to ra...@googlegroups.com
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.

Adrian

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/railo/e9f7e545-a72a-4a0d-92cc-7548d85eb27f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages