I have searched for hours trying to find out how to do this without any success.
I did find the 'FromGraphics' command which reads a 'system.drawing.graphics' object into the XGraphics type, but am unsure how to add this to the PDF output.
Most examples I find show how to take images from an existing file and save them to a PDF, but how do I do this with a pre-made system.drawing.graphics object that has been made pragmatically?
A C# and/or VB.net example would be very much appreciated instead of a GIF.
E.g. how do I change an example like the following to use the system.drawing.graphics object?
string pdfpath = Server.MapPath("PDFs");
string imagepath = Server.MapPath("Images");
Document doc = new Document();
try
{
PdfWriter.GetInstance(doc, new FileStream(pdfpath + "/Images.pdf", FileMode.Create));
doc.Open();
doc.Add(new Paragraph("GIF"));
Image gif = Image.GetInstance(imagepath + "/mikesdotnetting.gif");
doc.Add(gif);
}
catch (Exception ex)
{
//Log error;
}
finally
{
doc.Close();
}
Short example: