I’m using aspose.pdf for .net to search uploaded documents page-by-page for barcodes using the JPEG device to create an image of each page.
Based on the codes found, I then reassemble the document(s) and present them to the user for further processing.
The trouble comes with a certain set of pdf documents. I’ve not discovered the similarity of these documents, but on processing, a few things happen.
First, the JPEGDevice.Process method takes several minutes running in Visual Studio debug mode. Using compiled code, the process method takes less than a second.
The real trouble, however, is when i try to add the extracted page to a new pdf document. The exception received is: “Object not found.” The stack trace is not helpful. I’ve attached a sample document that’s giving us trouble.
Any assistance would be greatly appreciated.
foreach (Aspose.Pdf.Page pge in inputDoc.Pages)
{
try
{
using (MemoryStream imageStream = new MemoryStream())
{
jpegDevice.Process(pge, imageStream); //minutes in debug here, less than a second compiled code on the same machine.
barcodeImage = new Bitmap(imageStream);
}
if (barcodeImage != null)
{
string bcodes = DocumentBCReader.ReadBarcodes(barcodeImage);
barcodeImage.Dispose();
Aspose.Pdf.Document newDoc = new Aspose.Pdf.Document();
newDoc.Pages.Add(pge); //Exception Thrown here: Object not found.
using (MemoryStream pageStream = new MemoryStream())
{
newDoc.Save(pageStream);
ufUploadFile file = GetUploadFile(bcodes, pageStream, uploadedFileName, source);
filez.Add(file);
}
}
}
catch (Exception ex)
{
CommonBO.LogExceptionToDB(ex System.Reflection.MethodBase.GetCurrentMethod().Name);
filez.Clear();
barcodeImage.Dispose();
filez.Add(GetOriginalFile(inputDoc, uploadedFileName, source));
break;
}
}
at ..( ) at ..(Int32 , Int32 ) at ..() at ..() at ..( , Boolean ) at ..( , Boolean , Boolean ) at ..( , , Boolean ) at ..( , Boolean ) at ..( , Boolean , Boolean ) at ..( , , Boolean ) at ..( , Boolean ) at ..( , Boolean , Boolean ) at ..( , , Boolean ) at ..( , Boolean , Boolean ) at ..( , , Boolean ) at ..( , Boolean ) at ..( , Boolean , Boolean ) at Aspose.Pdf.PageCollection.(Page , , ) at Aspose.Pdf.PageCollection.(Page , ) at ABS2FileLib.DocumentBurster.GetFilesFromUploadFile(Stream stream, String uploadedFileName, DocumentControlData cdc) in C:\Users\lsafford\Documents\Visual Studio 2010\Projects\ABS2\ABS2FileLib\DocumentBurster.cs:line 86