Hi,
It appears that your forum doesn't allow files with the extension .svg. Maybe you should look into removing that rule. I've attached a gzip of my svg.
I'm not very familiar with Visual Studio, so I wouldn't know how to make a project from scratch. And since I'm only
working with PDFsharp in a tiny corner of the entire code base, I cannot isolate the code more than I've already done.
I can, however, paste some code that actually compiles
. Here follows the actual PDFSharpCrashClient with the crashing PDFSharp code, and a PDFSharpCrashClientTest that invokes the crashing code.
I've tried using the latest versions downloaded from your site: PDFSharp-MigraDocFoundation-1_32.zip and PDFSharp-MigraDocFoundation-1_31.zip, and even earlier version too. I've tried both WPF and GDI+. I'm currently using a NuGet package 1.32.3057.0, last published 10/15/2013. All crash with the same message I've stated above.
PDFSharpCrashClientCode:
namespace ReplacedNamespace
{
using System;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
public class PDFSharpCrashClient
{
public string CreatePdfWithStaticSvgImage ()
{
string desktopDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\";
string inputSvg = desktopDirectory + "chart.svg";
string outputPdf = desktopDirectory + "chart.pdf";
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XImage image = XImage.FromFile(inputSvg); // This crashes: System.OutOfMemoryException: Out of memory.
gfx.DrawImage(image, 0, 0);
document.Save(outputPdf);
document.Close();
return outputPdf;
}
}
}
PDFSharpCrashClientTestCode:
namespace ReplacedNamespace
{
using Xunit;
public class PDFSharpCrashClientTest
{
[Fact]
public void ShouldGeneratePdf ()
{
string outputPdf = new PDFSharpCrashClient().CreatePdfWithStaticSvgImage();
Assert.NotNull(outputPdf); // This Assert is never reached because the code above crashes.
}
}
}