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

Free Support Forum - aspose.com

Large MultiPage PDF generated using Aspose PDF 7.2

Thanks for testing out. By looking at your code, it seems like you have assigned a file path to PDF Image and iterate in a loop.


Even, I have tried out with your approach to create a single PDF.Page object & PDF.Image Object. Assigning a different file path in a loop and add it in Paragraph collection but it doesn’t work at all and throws an “out of memory” error.

As per my earlier post (refer below link), issue occurs when multiple single page tiff documents converted to a MultiPage PDF document. At that time, it will take large amount of memory.
Refer :

Consider the below scenario:

1. Take the Single page uncompressed image which I have given you in my first post - “img20140822_18405542.tif”,
2. Copy the Same document approx 55 times so that you have 55 single page tiff images in a folder.
3. Now, convert those 55 single page tiff documents to the PDF document so that it outputs single MultiPage PDF contains 55 pages.

Could you please share the sample application along with code which works on your machine so that I can have a look on it here. Also, share the machine details like RAM, Processor stuff etc…

Hi Dinesh,


Thanks for your feedback. We are looking into the issue and will let you know our findings soon.

Best Regards,

Hi Dinesh,


Thanks for sharing the details.

I have again tested the scenario where I have created 55 copies of (img20140822_18405542.tif) file and when using following code snippet in Visual Studio 2012 application with target platform as .NET Framework as 4.0 running over Windows 7(x64) where I have used 3.4 Ghz processor with 8 GB RAM and I am still unable to notice any issue. The PDF document is properly being generated.

[VB.NET]

Dim pdfDocument1 As Document = New Document()<o:p></o:p>

'r Each FilePath As String In FileNames

Dim pdfPage As Aspose.Pdf.Page = pdfDocument1.Pages.Add()

'Set margins so image will fit, etc.

pdfPage.PageInfo.Margin.Top = 0

pdfPage.PageInfo.Margin.Bottom = 0

pdfPage.PageInfo.Margin.Left = 0

pdfPage.PageInfo.Margin.Right = 0

Dim pdfImage As New Aspose.Pdf.Image()

Dim counter As Integer

For counter = 0 To 54

Console.WriteLine("--------" & counter)

pdfImage.File = fileEntries(counter)

'Add the image into paragraphs collection of the section

pdfPage.Paragraphs.Add(pdfImage)

Next

pdfDocument1.Save(“c:/pdftest/55_TIFF_Image_test.pdf”)

Hi,


We have tried the above mentioned code with latest Aspose.PDF 10.4 but we are still seeing size and Memory Consumption related issue with Aspose.PDF (DOM approach). However, we are not seeing any size & memroy consumption issue with Aspose.PDF.Generator.

For 55 Page like mentioned earlier in my thread; it throws an exception using DOM. Please give us the sample application so that I can have a look on it. Here is the sample code :

Dim pdfPage As Aspose.Pdf.Page = pdfDocument.Pages.Add()
Dim pdfImage As New Aspose.Pdf.Image()

'Set margins so image will fit, etc.
pdfPage.PageInfo.Margin.Top = 0
pdfPage.PageInfo.Margin.Bottom = 0
pdfPage.PageInfo.Margin.Left = 0
pdfPage.PageInfo.Margin.Right = 0


For Each FilePath As String In FileNames
pdfImage.File = FilePath

'Add the image into paragraphs collection of the section
pdfPage.Paragraphs.Add(pdfImage)
Next

pdfDocument.Save(OutPutPath)

Please refer Code Snippet for “Aspose.PDF.Generator” in my earlier thread which works for 55 Pages and also size is pretty less. Refer below link :
https://forum.aspose.com/t/68080

Moreover, I had an issue with HTML To PDF Conversion with Aspose.PDF.Generator which works with DOM appraoch. Refer below thread :
<a href="
Please suggest recommended approach which works for all cases.

Kindly Consider it as Critical.

Hi Dinesh,


Thanks for sharing the details.

I have tested the scenario using Aspose.Pdf for .NET 10.4.0 using followig code snippet and I am unable to notice any issue. As per my observations, the 55 copies of TIFF image are converted to single PDF file in 83 seconds.

[VB.NET]

Dim pdfDocument As Document = New Document()<o:p></o:p>

Dim pdfPage As Aspose.Pdf.Page = pdfDocument.Pages.Add()

Dim pdfImage As New Aspose.Pdf.Image()

'Set margins so image will fit, etc.

pdfPage.PageInfo.Margin.Top = 0

pdfPage.PageInfo.Margin.Bottom = 0

pdfPage.PageInfo.Margin.Left = 0

pdfPage.PageInfo.Margin.Right = 0

' Retrieve names of all the Pdf files in a particular Directory

Dim FileNames() As String = Directory.GetFiles("C:\pdftest\Copies\", "*.tif")

For Each FilePath As String In FileNames

pdfImage.File = FilePath

'Add the image into paragraphs collection of the section

pdfPage.Paragraphs.Add(pdfImage)

Next

pdfDocument.Save(“C:\pdftest\ConvertedResultant.pdf”)

Could you share the sample application so that I can have a look on it ? I am using .Net Framework 4.5 Windows Application & Aspose.PDF 10.4 dll (from .net 4.0 folder) ?

Attached are my machine details.

Hi Dinesh,


I have again tested the scenario while setting target framework as .NET Framework 4.5 and still unable to notice any issue. The process of conversion is completed in 86 seconds. For your reference, I have also attached the sample project which I am using in my environment.

Thanks for sharing the sample application. I have tested the application and it works fine. However, the same code not works on my sample application. I will compare the project settings with your project to better understand what causing the issue. So that’s on my plate.


Still I see the Large Multipage PDF is generated using DOM approach like I earlier mentioned. See below findings
  • Using DOM approach - Result PDF size goes to approx 75 MB (for 55 Page which equals to 55 MB)
  • Using Generator appraoch - Result PDF size goes to approx 8 MB.(for 55 Page which equals to 55 MB)

Refer below link for Generator code which i am using : https://forum.aspose.com/t/68080

Please let me know Could we achieve the same PDF Size in DOM approach.

Hi Dinesh,


Thanks for sharing the details.

I have tested the scenario and have observed that when placing 55 copies of TIFF image to PDF file, the resultant file of 74 MB is being generated. For the sake of correction, I
have logged it in our issue tracking system as
PDFNEWNET-38809. We will investigate this
issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

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