Aspose.PDF for .NET Adding Extracted Page to New PDF Fails

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

lsafford:
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.
Hi Lance,

Thanks for using our products.

I have tested the scenario using Aspose.Pdf for .NET 7.0.0 in a VisualStudio 2010 project where I have set the target platform of my application as X86 and as per my observations, when using the application in Debug mode, the process is completed in 5 minutes and 44 seconds whereas when tested under Release mode, the process is completed in 9 minutes and 17 seconds. Can you please share some details regarding the issue that you observed where Debug mode is taking much time as compare to Compiled mode.

However I have logged this above stated problem as PDFNEWNET-33767 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction.

lsafford:
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

I have managed to reproduce this problem and it has been logged as PDFNEWNET-33766 in our issue tracking system. Our development team will further look into the details of this problem and we will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for your inconvenience.

The issues you have found earlier (filed as PDFNEWNET-33766;PDFNEWNET-33766) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as PDFNET-33767) have been fixed in Aspose.PDF for .NET 25.11.