Svg to pdf conversion problem with railo 3.1.x

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? Thanks.

svgfile = FileReadBinary("#ExpandPath('..\svgFiles')#\123.svg"); file = toBase64(svgfile);


    <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”>
—>

    <cfdocument format="pdf" overwrite="yes" filename="#aPDF.pdf" 

localurl=“true”>
<!—

—>
the header
the footer


<!— it works! —>



    <!---
    <cfreturn SerializeJSON(form) />
    --->
</cffunction>

Thanks for the pointer about imageMagick. Went to git, under Files, it
lists tons of stuffs…

You could just do an imageMagick conversion and call it via cfexecute.

If you want to do it in CF, you could at least look at the source for
imageMagick and you might be able to gleam on how they handle SVG file
conversation and adapt it accordingly.

On Thursday, October 1, 2015 at 10:14:32 PM UTC-4, lovera...@gmail.com wrote:

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? Thanks.

svgfile = FileReadBinary("#ExpandPath('..\svgFiles')#\123.svg"); file = toBase64(svgfile);


    <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”>
—>

    <cfdocument format="pdf" overwrite="yes" filename="#aPDF.pdf" 

localurl=“true”>
<!—

—>
the header
the footer


<!— it works! —>



    <!---
    <cfreturn SerializeJSON(form) />
    --->
</cffunction>

You could just do an imageMagick conversion and call it via cfexecute.

If you want to do it in CF, you could at least look at the source for
imageMagick and you might be able to gleam on how they handle SVG file
conversation and adapt it accordingly.On Thursday, October 1, 2015 at 10:14:32 PM UTC-4, lovera...@gmail.com wrote:

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? Thanks.

svgfile = FileReadBinary("#ExpandPath('..\svgFiles')#\123.svg"); file = toBase64(svgfile);


    <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”>
—>

    <cfdocument format="pdf" overwrite="yes" filename="#aPDF.pdf" 

localurl=“true”>
<!—

—>
the header
the footer


<!— it works! —>



    <!---
    <cfreturn SerializeJSON(form) />
    --->
</cffunction>

Thanks for the note, however, Batik solution, imho, is too convoluted.
I’ll take another approach now.On Saturday, October 3, 2015 at 6:53:54 AM UTC-4, Denard Springle wrote:

The solutions shown in these blog posts should be similar for your
situation. You should just be able to call Batik and do the conversion to
PNG/JPG following those examples - you may need the batik jars, can’t
recall if they’re already in Railo 3.1

http://www.learnsomethings.com/2012/11/20/saving-svg-to-png-on-your-cold-fusion-server/

http://www.glenncrocker.com/2009/10/svg-to-png-on-the-fly-with-coldfusion/

https://rickosborne.org/blog/category/programming/coldfusion/page/53/

Hope that helps!

– Denny

The solutions shown in these blog posts should be similar for your
situation. You should just be able to call Batik and do the conversion to
PNG/JPG following those examples - you may need the batik jars, can’t
recall if they’re already in Railo 3.1

http://www.learnsomethings.com/2012/11/20/saving-svg-to-png-on-your-cold-fusion-server/

https://rickosborne.org/blog/category/programming/coldfusion/page/53/

Hope that helps!

– Denny

ImageMagik core I would guess would be correct one.On Thursday, October 1, 2015 at 10:14:32 PM UTC-4, lovera...@gmail.com wrote:

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? Thanks.

svgfile = FileReadBinary("#ExpandPath('..\svgFiles')#\123.svg"); file = toBase64(svgfile);


    <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”>
—>

    <cfdocument format="pdf" overwrite="yes" filename="#aPDF.pdf" 

localurl=“true”>
<!—

—>
the header
the footer


<!— it works! —>



    <!---
    <cfreturn SerializeJSON(form) />
    --->
</cffunction>