Any simple way to convert/save/export a svg file into a PDF doc?

320 views
Skip to first unread message

lovera...@gmail.com

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

I'm  on Railo 3.1.x (for Windows).

Code Set 1
----------------

The following code executes, however, the svg is not saved into the target PDF doc. 

(removing the mimeType="image/svg" attribute resulted in the same outcome)

<cfdocument format="pdf" filename="#ExpandPath('images')#\aPDF.pdf" mimeType="image/svg" overwrite="yes">
<cfoutput>
<img src="#ExpandPath('..\svgfiles')#\123.svg" />
</cfoutput> 
</cfdocument>



Code Set 2
----------------
<!--
(1) read the svg file in binary
 FileReadBinary
 -->
<cfscript>
    svgfile = FileReadBinary("#ExpandPath('..\svgfiles')#\123.svg");
    sFile = toBase64(svgfile);
</cfscript>

<!---
<cfoutput>
<img src="data:image/png;base64, #svgfile#]"/>
</cfoutput>
<!-- the above showed some promise -->
--->

<!--- (2) read the base 64 representation of the image --->
<!---
<cfset cfImageObject = ImageReadBase64(svgfile) />
--->
       
<!--- create a new cf image object --->
<!---
<cfimage source="#cfImageObject#" destination="aPng.png" action="write" overwrite="yes">
--->

<cfimage source="#sFile#" destination="#ExpandPath('images')#\bPng.png" action="write" overwrite="yes">

<cfdocument format="pdf" overwrite="yes" filename="#ExpandPath('images')#\bPDF.pdf">

    <cfdocumentitem type="header">the header</cfdocumentitem>
    <cfdocumentitem type="footer">the footer</cfdocumentitem>
    <cfdocumentsection>
        <cfoutput>
            <!--- it works! --->
            <img src="#ExpandPath('images')#\bPng.png" />
        </cfoutput>
    </cfdocumentsection>     
</cfdocument>

The above code fails with err msg of "can't find Format of given image".

How is it supposed to be done?

Thanks.

Reply all
Reply to author
Forward
0 new messages