When attempting to convert from PDF to XPS with Spire.PDF (Free) and we are getting a GDI+ exception: "Bitmap region is already locked."
Stack trace:
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Single x, Single y, Single width, Single height)
at System.Drawing.Graphics.DrawImage(Image image, RectangleF rect)
at sprᜢ.ᜀ(Graphics A_0, spr A_1, spr᪨ A_2)
at spr᪨.ᜄ(String[] A_0)
at spr᪨.ᜀ(sprᯩ A_0)
at spr᪨.ᜄ(Boolean A_0)
at Spire.Pdf.PdfDocumentBase.ᜁ(Stream A_0, Int32 A_1)
at sprᴰ.ᜁ(PdfDocumentBase A_0, Stream A_1)
at sprᴰ.ᜃ(PdfDocumentBase A_0, Stream A_1)
at Spire.Pdf.PdfDocumentBase.SaveToXPS(String savefilename)
at Spire.Pdf.PdfDocumentBase.Save(String fileName, FileFormat fileformat)
at Spire.Pdf.PdfDocument.SaveToFile(String filename, FileFormat fileFormat)
at Kare.DocumentPrinter.print_Click(Object sender, EventArgs e)
This happens with every PDF file we try to convert.
The code is as follows:
string pdfFile = @"c:\temp\test.pdf";
string xpsPath = Path.ChangeExtension(pdfFile, ".xps");
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile(pdfFile);
doc.SaveToFile(xpsPath, Spire.Pdf.FileFormat.XPS);
doc.Close();
I attempted to attach a PDF to test with (as it could perhaps be something with the PDF we're generating that's causing the issue), but apparently .PDF files cannot be uploaded as attachments.
I've attempted running the code compiled as "Any CPU", x64, and x86 all with the same result.
This is on a Win 7 x64 machine.
Any assistance would be appreciated!
Thanks,
-Will