I've been trying to convert SVG images to PNG using C#, without having to write too much code. Can anyone recommend a library or example code for doing this?
From stackoverflow
-
You can call the command-line version of incscape to do this:
http://harriyott.com/2008/05/converting-svg-images-to-png-in-c.aspx
Also there is a C# SVG rendering engine, primarily designed to allow SVG files to be used on the web on codeplex that might suit your needs if that is your problem:
harriyott : Thanks Espo. I actually wrote that inkscape blog post! Although it "works", it's not a particularly robust solution. I like the codeplex project though - I'll give it a look. Thanks.Espo : How embarrassing :) Good thing maybe the SVG rendering engine could help you out though.harriyott : I take it as a compliment. I've not been quoted to myself before!Jeff Atwood : that's hilarious! :) -
Couldnt help noticing:
@harriyott Isnt it your site www.harriyott.com??
Espo : Haha, didn't notice that. Maybe he allready know about the incscape-trick then :) But the SVG-rendering might help him if he needs to display svg-images on the web.Prakash : yes, thats a nice link! +1 2 u.. -
I'm using Batik for this. The complete Delphi code:
procedure ExecNewProcess(ProgramName : String; Wait: Boolean); var StartInfo : TStartupInfo; ProcInfo : TProcessInformation; CreateOK : Boolean; begin FillChar(StartInfo, SizeOf(TStartupInfo), #0); FillChar(ProcInfo, SizeOf(TProcessInformation), #0); StartInfo.cb := SizeOf(TStartupInfo); CreateOK := CreateProcess(nil, PChar(ProgramName), nil, nil, False, CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil, nil, StartInfo, ProcInfo); if CreateOK then begin //may or may not be needed. Usually wait for child processes if Wait then WaitForSingleObject(ProcInfo.hProcess, INFINITE); end else ShowMessage('Unable to run ' + ProgramName); CloseHandle(ProcInfo.hProcess); CloseHandle(ProcInfo.hThread); end; procedure ConvertSVGtoPNG(aFilename: String); const ExecLine = 'c:\windows\system32\java.exe -jar C:\Apps\batik-1.7\batik-rasterizer.jar '; begin ExecNewProcess(ExecLine + aFilename, True); end;
-
you can use altsoft xml2pdf lib for this
0 comments:
Post a Comment