OutOfMemoryException

OutOfMemoryException

Forum member · Jun 20, 2007
Hi Dear, I am evaluating DynamicPDF Merger .Net 4.x but I get OutOfMemoryException when I execute this code: private void MergePDFs() { string outFile = @"D:\ClientStatement\June-2007\ShipForPrinting\MergedStatements-June2007.pdf"; MergeDocument pdfMerge = new MergeDocument(); pdfMerge.CompressionLevel = 9; pdfMerge.PdfVersion = PdfVersion.v1_7; foreach (string pdfFilePath in PDFFilesList(@"D:\ClientStatement\June-2007")) { pdfMerge.Append(pdfFilePath); } pdfMerge.Draw(outFile); } Am I missing anything? or the product cannot handle this? Is there away to get the MergeDocument to write to the disk as the merging progesses? Note that I am trying to merge 8000 documents and the toal size is 700MB. I am using a powerful PC with 2GB memory but still DynamicPDF Merged failed to merge my files. Thanks Regards Karim

Re: OutOfMemoryException

Support · Jun 21, 2007
Hello Karim, Can you please send couple of PDF files you are merging to our [^a|mailto:support@cete.com|Support Team^] so that they can take a look at the version of PDF you are merging. If the PDF documents have cross reference stream in them, they will be expanded when merging and that will result in utilization of more resources and memory. Thanks, ceTe Software Support Team

Re: OutOfMemoryException

Forum member · Nov 16, 2007
I am facing the some message when drawing a 300 MB document. See the code below: public class pdf { private byte[] bDoc; public void openPdf(){ MergeDocument md = new MergeDocument(@"c:\mypdf.pdf"); this.bDoc = md.draw(); } public void ResizePages(float width, float height,bool doublePage) { Document newDoc = new Document(); PdfDocument pdf = new PdfDocument(this.bDoc); float pgHeight = pdf.Pages[0].GetDimensions().Height; float pgWidth = pdf.Pages[0].GetDimensions().Width; float paperReductionFactor = PDFHelper.getPageReductionFactor(doublePage, (width * Point.PT_IN_1MM), (height * Point.PT_IN_1MM)); float reductionFactor = PDFHelper.getReductionFactor(pgWidth,pgHeight, doublePage, (width * Point.PT_IN_1MM), (height * Point.PT_IN_1MM)); float newPaperWidth = (width * Point.PT_IN_1MM) + Point.PT_IN_1CM * paperReductionFactor; float newPaperHeight = (height * Point.PT_IN_1MM) + Point.PT_IN_1CM * paperReductionFactor; foreach (PdfPage pg in pdf.Pages) { ImportedPageData ipd = new ImportedPageData(pg); ipd.Width = (width * Point.PT_IN_1MM) + Point.PT_IN_1CM * reductionFactor; ipd.Height = (height * Point.PT_IN_1MM) + Point.PT_IN_1CM * reductionFactor; Page newPage = new Page(newPaperWidth, newPaperHeight, 0f); newPage.Elements.Add(ipd); newDoc.Pages.Add(newPage); } pdf = null; this.bDoc = null; this.bDoc = newDoc.Draw(); } }

Re: OutOfMemoryException

Forum member · Nov 16, 2007
Additional information ro the previous post... Thanks, Bazili DPX.Common.Util.BaseException: Erro de extração ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.IO.MemoryStream.set_Capacity(Int32 value) at System.IO.MemoryStream.EnsureCapacity(Int32 value) at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count) at zz93.ab.b(Byte[] A_0, Int32 A_1, Int32 A_2) at zz93.ab.c(Byte[] A_0, Int32 A_1, Int32 A_2) at zz93.cw.a(DocumentWriter A_0) at zz93.a0.a(DocumentWriter A_0) at ceTe.DynamicPDF.IO.DocumentResourceList.a(DocumentWriter A_0) at zz93.ab.v() at ceTe.DynamicPDF.Document.Draw() at DPX.Common.Util.PdfFile.ResizePages(Single width, Single height, Boolean doublePage) at DPX.Common.BusinnesLogic.TTPS.ExtractorPages.FileExtracted(DataRow dr, String pdfCoverFilePath, String pdfPagesFilePath)