We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.PDF gives me an 'out of memory' error on trying to process large PDF file

Hi,

I am getting ‘out of memory’ error on trying to convert large PDF 164 MB (about 6000 pages) into single page tiffs. I am using 11.2.0. 0 version of Asp.PDF.dll.

Here is the code i am using

// bind the pdf document
Aspose.Pdf.Facades.PdfExtractor pdfExtractor = new Aspose.Pdf.Facades.PdfExtractor();
pdfExtractor.BindPdf(fileToProcess.FullName);

// set page range for image extraction
//pdfExtractor.StartPage = 1;
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(fileToProcess.FullName);
int pageCount = pdfDocument.Pages.Count;

// create Resolution object with 300 as an argument
Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);

//create TiffSettings object
Aspose.Pdf.Devices.TiffSettings tiffSettings = new Aspose.Pdf.Devices.TiffSettings();
tiffSettings.Compression = Aspose.Pdf.Devices.CompressionType.CCITT4;
tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;
//tiffSettings.Shape = Aspose.Pdf.Devices.ShapeType.Portrait;
tiffSettings.SkipBlankPages = false;
//create TIFF device
Aspose.Pdf.Devices.TiffDevice tiffDevice = new Aspose.Pdf.Devices.TiffDevice(resolution, tiffSettings);

int i = 0;
for (i = startPageCount; i <= endPageCount; i++)
{

//var converter = new Aspose.Pdf.Facades.PdfConverter();
//converter.BindPdf(fileToProcess.FullName);
//converter.StartPage = i;
//converter.EndPage = i;
//converter.DoConvert();
pdfExtractor.StartPage = i;
pdfExtractor.EndPage = i;
pdfExtractor.ExtractImage();

while (pdfExtractor.HasNextImage())
{
Console.WriteLine(“Getting next image…”);
// save image to stream
MemoryStream imageStream = new MemoryStream();
pdfExtractor.GetNextImage(imageStream);
imageStream.Position = 0;

strNewDirectory = “C:\AFLAC_Processing\XDS Exporter\Export\Agent Services”;
strNewImage = i.ToString(“00000”) + “.TIF”;
tiffDevice.Process(pdfDocument, i, i, strNewDirectory + @"" + strNewImage);

}
}

Hi Wayne,


Thanks for contacting support.

Please note that you are using an old version of our API. It is always recommended to use latest version of Aspose.Pdf which can be downloaded from the Downloads section. Moreover I am afraid that you are using old Aspose.Pdf.Facades approach which is going to be obsolete soon. It is recommended to use new DOM (Aspose.Pdf) approach. Please check the following code snippet to convert all pages into single TIFF using new DOM approach.

Document pdfDocument = new Document(“input.pdf”);<o:p></o:p>

Resolution resolution = new Resolution(300);

TiffSettings tiffSettings = new TiffSettings();

tiffSettings.Compression = CompressionType.None;

tiffSettings.Depth = ColorDepth.Default;

tiffSettings.Shape = ShapeType.Landscape;

tiffSettings.SkipBlankPages = false;

TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);

tiffDevice.Process(pdfDocument, "AllPagesToTIFF_out.tif");



You may check "Convert PDF Pages" to convert all pages into one TIFF using new DOM approach. Please try converting your document with latest version of our API and new DOM approach. In case if you still face any issue please share a sample PDF document so that we can try to replicate the issue in our environment and update you accordingly.

We are sorry for the inconvenience.

Best Regards,

Hi Wayne,


Adding more to Asad’s comments, our forums support uploading the files upto 25 MB and in order to upload larger PDF files, please try uploading them to some free file sharer and and share the link with us.

Hi,


I have used DOM but it continue to give an out of memory after converting around 3000 pages to tiffs. Other requirement i was given is to read the barcode from the PDF. So requirement was to read the 2d barcode from each page of PDF and also convert each page to tiff image.

It appears i need to purchase new version of aspose.pdf since 1 year period expired. Do you have any customer that has this requirement to read 2d barcode and convert to tiff from a large PDF that has 5000 pages or more?

I want to make sure latest software would be able to that before i ask my manager to purchase an upgrade.

Hi Wayne,


Thanks for sharing more details.

wbarber:
I have used DOM but it continue to give an out of memory after converting around 3000 pages to tiffs.

I have tried converting large PDF file (i.e ~94MB, 1624 pages) into TIFF and was unable to notice any out of memory exception at my end. As shared earlier that we will really appreciate if you please share a sample input file so that we can try to reproduce the issue in our environment. If your file is of larger size then you can upload it to any file hosting server and share its link with us.

wbarber:
Other requirement i was given is to read the barcode from the PDF. So requirement was to read the 2d barcode from each page of PDF and also convert each page to tiff image.

To read barcode from PDF you can use Aspose.Barcode and then Aspose.Pdf to convert PDF page(s) into TIFF. You may check “Recognize Barcode from PDF Document” section in API documentation.

wbarber:
It appears i need to purchase new version of aspose.pdf since 1 year period expired.
wbarber:
I want to make sure latest software would be able to that before i ask my manager to purchase an upgrade.

You may apply a temporary license to test the product and later you may consider renewal of the subscription. To check the renewal policies you can visit “Renewal Policies” page and to get a temporary license, please check “Get a Temporary License” page.

If you need any further assistance please feel free to contact us. We are sorry for the inconvenience.

Best Regards,