In my application, I have a document upload capability. Once the document reaches my web server, I convert it to an Aspose.PDF document from the original string. Next the app converts the pages one-by-one to bitmaps from which it looks for barcodes on the image. About half of the time on my production environment, the JPEGDevice throws the exception below: "Parameter is not valid."
This happens about half the time on my production environment. I've never seen it on any other environments.
Can you shed any light on why this exception is being thrown? Is the stream invalid or is the document page invalid? If the page, does that imply that the page and hence the parent document is corrrupted in some fashion?
I should have said, the documents where the exception is throw may upload and be read successfully during a subsequent trial or on our other environments. Likely it is not a problem with the specific documents.
I've included the stack trace from the exception below and a simplified version of my code.
Thanks.
Lance Safford
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at ...ctor(? , )
at .?.(? , )
at .?..ctor( , ? )
at ..( , ? )
at .?.()
at Aspose.Pdf.Devices.ImageDevice.(Page )
at Aspose.Pdf.Devices.JpegDevice.Process(Page page, Stream output)
Aspose.Pdf.Document inputDoc = new Aspose.Pdf.Document(stream);
Aspose.Pdf.Devices.JpegDevice jpegDevice = new Aspose.Pdf.Devices. JpegDevice(new Aspose.Pdf.Devices.Resolution(int.Parse(ABS2FileLibRes.imageResolution)), int.Parse(ABS2FileLibRes.imageQuality));
bool barcodesFound = true;
foreach (Aspose.Pdf.Page pge in inputDoc.Pages)
{
using (MemoryStream imageStream = new MemoryStream())
{
//exception is thrown from the line below
jpegDevice.Process(pge, imageStream);
//
barcodeImage = new Bitmap(imageStream);
}
//do application stuff
}