I need a big hand here, cannot solve and have spent significant time troubleshooting without success.
I am using Spire.PDF to convert a PDF to an image BLOB, so that I may store it in a database. In testing, I've generalized this down to simply saving as an image and removed the whole BLOB from the equation.
I've attached two documents:
1) TestDocument.pdf - the original PDF document which I convert to an image BLOB.
2) TestDocument.jpeg - the saved image of the loaded PDF.
The code is very obvious and straight-forward - I load the PDF document, save it to a second file (to confirm the PDF save works correctly), write it to an image object, save the image to the desktop and then as a byte array (which I would later use to insert into a database).
The problem is that the text at the bottom is being flipped - you can see the original text within the TestDocument PDF, and then looking at the image something very weird has happened...
- Code: Select all
byte[] streamText = null;
PdfDocument pdfDoc = new PdfDocument();
Image img = null;
MemoryStream imageStream = null;
pdfDoc.LoadFromFile("C:\\Users\\curtis.watson\\Desktop\\TestDocument.pdf");
pdfDoc.SaveToFile("C:\\Users\\curtis.watson\\Desktop\\TestDocument2.pdf");
img = pdfDoc.SaveAsImage(0, Spire.Pdf.Graphics.PdfImageType.Bitmap, 96, 96);
imageStream = new MemoryStream();
img.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
img.Save("C:\\Users\\curtis.watson\\Desktop\\TestDocument.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
streamText = imageStream.ToArray();