Jump to content
Sign in to follow this  
misc_bb

Reading SVG code from text file

Recommended Posts

We are currently dealing with rendering SVG images dynamically and we want to render the SVG using the svg code. Reading the svg code from a text file causing some text to be converted to something. What's the best approach for this one? Convert to UTF-8?

Currently trying to create using a TMemoryStream then save the stream to a file via ImageEN but svg text/code gets converted to ascii.

Edited by misc_bb

Share this post


Link to post

Clearly there is a problem but you'd need to provide information on what the data is and precisely how you are processing it before you can get specific help. One thing I can probably say with confidence is that you are falling into the well know Delphi memory stream anti pattern. 

Share this post


Link to post

Since SVG is composed of XML, I also tried using XMLdocument but loading the content of the file already gave me errors probably because of text layers? (but i still test it again). So basically reading the file or encoding it probably hopefully is the way to go. 

Share this post


Link to post
46 minutes ago, misc_bb said:

We are currently dealing with rendering SVG images dynamically and we want to render the SVG using the svg code. Reading the svg code from a text file causing some text to be converted to something. What's the best approach for this one? Convert to UTF-8?

Currently trying to create using a TMemoryStream then save the stream to a file via ImageEN but svg text/code gets converted to ascii.

I'm somewhat confused by your questions. Your first sentence implies you're wanting to bypass the rendering done by ImageEN (mentioned in your fourth sentence). Is that your intention? If so, are you intending to write your own SVG parser and renderer?

Share this post


Link to post

@angusj Not really my intention to bypass. But basically we just want to create the svg file directly using the svg code. In the processing context, I'm not sure exactly if it bypasses the rendering process. I hope I am making sense now 🙂

 

I was happy working with Image32 but boss wants me to use ImageEN because he purchased it :classic_biggrin: 

Edited by misc_bb

Share this post


Link to post
18 minutes ago, misc_bb said:

Not really my intention to bypass. But basically we just want to create the svg file directly using the svg code

OK, so if I understand you correctly, you're wanting to create SVG files but use ImageEN to read and render them.

My strong recomendation is to create SVGs in UTF-8 format. SVGs were initially designed for web display and it's very rare to find an SVG file that isn't UTF-8 encoded (and just about everything web related is UTF-8). HTHs.

 

Share this post


Link to post

yes, I think I'm on that direction now as I continue testing and working out a solution. Thanks @angusj

 

Got it figure out now! Thanks everyone!

Edited by misc_bb

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×