0

I would like to use iText to add images to some PDF-documents using C#.

My problem is, that the images are saved as a stream (fx. M47,33 L47,34 L47,37 L47,40 L47 etc.) in the database.

I can't figure out, how to convert this to PNG or JPEG so I can add them to the PDF-documents.

Can anyone tell me how to make this convertion, or if it can be done directly in iText?

Christian Tang
  • 1,450
  • 4
  • 19
  • 30
  • This question is related: http://stackoverflow.com/questions/1525421/drawing-svg-in-net-c – Andre Mar 26 '12 at 13:23

2 Answers2

2

Converting SVG images to png in c#

daryal
  • 14,643
  • 4
  • 38
  • 54
  • 1
    The linked article describes an "interesting" way of conversion if you don't mind calling Inkscape via its command-line interface (which brings some more points of failure to your application). – Andre Mar 26 '12 at 13:27
  • As described in a comment below, I'm not able to install third-party software on the customer's server. As far as I understand, this rules out InkScape? – Christian Tang Mar 26 '12 at 15:16
0

You could use http://librsvg.sourceforge.net/

It does not have a C# binding as far as I can see, but it should be possible to use it via P/Invoke.

EDIT: iText seems to have some conversion, too: http://itextpdf.com/examples/iia.php?id=263

Andre
  • 1,577
  • 1
  • 13
  • 25
  • As mentioned in the question, I'm using c# for my application. The example from iText is written in Java. – Christian Tang Mar 26 '12 at 13:48
  • At this moment I just need to get something running on my desktop PC (proof of concept). The final "program" will be running in an ASP.NET-appication on the customer's server. I also won't be able to install any third-party software on the server, so I guess InkScape (mentioned in a lot of guides), isn't an option. – Christian Tang Mar 26 '12 at 13:52
  • Sorry for the Java sample ;-) But what about using librsvg with P/Invoke? – Andre Mar 26 '12 at 13:54
  • Havn't gotten around to librsvg yet. Librsvg seems like a lot of work to achieve a simple thing. I have found several guides which all use a c# MemoryStream for convertion. I can't get any of these examples to work. This is strange, because I even found it on MSDN. – Christian Tang Mar 26 '12 at 14:18