Using this code I'm able to create a pdf using version 1.32
Code:
var doc = new PdfDocument();
var p = doc.AddPage();
p.Size = PageSize.A4;
using (XImage xImg = Image.FromFile(@"c:\temp\test.jpg"))
{
using (XGraphics xGfx = XGraphics.FromPdfPage(p))
{
xGfx.DrawImage(xImg, new XRect(0.0, 197.875, 595, 446.25), new XRect(0, 0, p.Width, p.Height), XGraphicsUnit.Point);
}
p.Close();
}
doc.Save(@"c:\temp\" + Guid.NewGuid().ToString() + ".pdf");
doc.Close();
But in version 1.50 Beta it ends with the following exception:
Code:
Could not find file 'C:\temp\testproject\bin\Debug\edff2edc-82ca-4b1b-9e28-3dba72f52865'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.OpenRead(String path)
at PdfSharp.Pdf.Advanced.PdfImage.InitializeJpeg()
at PdfSharp.Pdf.Advanced.PdfImage..ctor(PdfDocument document, XImage image)
at PdfSharp.Pdf.Advanced.PdfImageTable.GetImage(XImage image)
at PdfSharp.Pdf.PdfPage.GetImageName(XImage image)
at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.GetImageName(XImage image)
at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.Realize(XImage image)
at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.DrawImage(XImage image, XRect destRect, XRect srcRect, XGraphicsUnit srcUnit)
at PdfSharp.Drawing.XGraphics.DrawImage(XImage image, XRect destRect, XRect srcRect, XGraphicsUnit srcUnit)