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

Skip to first unread message

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

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">
<img src="#ExpandPath('..\svgfiles')#\123.svg" />

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

<img src="data:image/png;base64, #svgfile#]"/>
<!-- 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>
            <!--- it works! --->
            <img src="#ExpandPath('images')#\bPng.png" />

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

How is it supposed to be done?


Reply all
Reply to author
0 new messages