Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Nov 03, 2015 12:12 pm

Hello,
I have about 30 directories in my file system, which contain pdf documents created by spire.pdf.
Their single dimension goes from 40 to 70 kb.
Each directory contains about 30-40 pdf files.
I run my code,
and after a while it goes in Out of memory on the doc.save command.
I post my code:

Dim PathUnique As String = ""
Dim PathNumFile As String = ""
Dim i As Int32 = 0
For Each SubDire As String In My.Computer.FileSystem.GetDirectories _
(MiaDire)
PathUnique = DirDeposito
Dim getInfo As System.IO.DirectoryInfo
getInfo = My.Computer.FileSystem.GetDirectoryInfo _
(SubDire)

Dim NumeraFile As Int32 = -1
Dim FilesLetti As Int32 = 0
For Each MySingePdf As String In My.Computer.FileSystem.GetFiles _
(SubDire)

If MensilePdf.Contains("Mensile") Then
' I merge only 30 pdf into one, to avoid a loo large dimension
If FilesLetti = 0 Then
NumeraFile = NumeraFile + 1
PathNumFile = PathUnique & getInfo.Name & Convert.ToString(NumeraFile) & ".PDF"
Try
My.Computer.FileSystem.DeleteFile(PathNumFile)
Catch ex As System.IO.FileNotFoundException
Catch ex As IOException
End Try
End If
Dim DlWritePage As New Classi.Runtime.WritePageP
DlWritePage.UnifyPdf(PathNumFile, MySinglePdf, errore)
DlWritePage = Nothing
FilesLetti = FilesLetti + 1
If FilesLetti = 30 Then FilesLetti = 0

End If

Next

Next

Here is the DlWritePage.UnifiPdf function:
Friend Function UnifyPdf(ByVal PathNumFile As String, ByVal MySinglePdf As String, ByRef Errore As String) As Boolean

UnifyPdf = True

If Not My.Computer.FileSystem.FileExists(PathNumFile) Then
Dim docempty As New PdfDocument()
docempty.LoadFromFile(MySinglePdf)
docempty.SaveToFile(PathNumFile)
docemptyvuoto.Close()
docemptyvuoto.Dispose()
docemptyvuoto = Nothing
Else
Dim files As String() = New String() {PathNumFile, MySinglePdf}
Dim doc As PdfDocumentBase = PdfDocument.MergeFiles(files)
doc.Save(PathNumFiles, Spire.Pdf.FileFormat.PDF)
doc.Dispose()
doc.Close()
doc = Nothing
End If

End Function

Can anyone help me?
My computer has a 3.5GB RAM, 1.9GB free
thank you.
Paola

paolagumi
 
Posts: 81
Joined: Tue Apr 21, 2015 11:32 am

Wed Nov 04, 2015 3:50 am

Hello Paola,

Thanks for your inquiry.
Did happen the error when you merged 30 pdf files?
I have forwarded your issue to our dev team. We will inform you when there is any update on it.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Wed Nov 04, 2015 7:26 am

Yes,
first I tried with 50 files,
after some files it merged correctly (of 50 each), sudddenly it went in out of memory.
So I tried to merge only 30, but the problem persisted.
The error doesn't occur always on the same file, because it depends on the memory occupation of the moment.
When I see the task manager, I see my process occupying memory increasing continuately,
as if every merged file stayed in memory (even if I wrote the statements like "doc = nothing"...to free memory)
thank you,
I wait for your answer.
Paola

paolagumi
 
Posts: 81
Joined: Tue Apr 21, 2015 11:32 am

Wed Nov 04, 2015 8:08 am

Hello Paola,

We did a testing with 50 pdf files, and it smoothly finished merging. To help us recreate your issue and resolve it soon, please provide us with your pdf files, the better is your project, also tell us your operating system environment.

Thanks.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Wed Nov 04, 2015 8:28 am

With only 50 pdf files merged into one it works also to me,
but if I do this merge of 50 files into one too many times, it goes out of memory.
I attach one of my pdf files.
My computer has Windows 7, I work with visual studio 2010.
best regards,
Paola

paolagumi
 
Posts: 81
Joined: Tue Apr 21, 2015 11:32 am

Wed Nov 04, 2015 8:54 am

Hi Paola,

Thanks for further information and document.
We will further investigate the issue. When there is new update, we will tell you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Thu Nov 05, 2015 7:15 am

Hi Paola,

I did a testing with your document and Spire.PDF Pack(Hot Fix) Version:3.5.143. It is to merge 50 files into one for 2000 times. All went well.
This is my test code:
Code: Select all
 for (int i = 0; i < 2000;i++)
            {
                List<string> aa = new List<string>();
               //This folder contains 50 files and they have the same content as [i]Mensile201507P11397.PDF[/i].
                DirectoryInfo TheFolder = new DirectoryInfo("..\\..\\6160");
                foreach (FileInfo file in TheFolder.GetFiles())
                {
                    aa.Add(file.FullName);
                }

                string[] files = aa.ToArray();
                PdfDocumentBase merged = PdfDocument.MergeFiles(files);
                merged.Save(string.Format("..\\..\\output\\merged-{0}.pdf",i+1));
            }


We guess that there may be other document you used to merge caused the issue in analysing. Please send us more documents, the better is to provide us with your project if you can, which will help us recreate your issue and resolve it soon. And also please tell us your complete operation system information, for example, Windows 7 Enterprise Edition SP1 x64
Regional and Language Options.
If you cannot share your files here, please send them to amy.zhao@e-iceblue.com.

Thanks.
Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Thu Nov 05, 2015 11:01 am

Hello Amy,
I tried your same test and I encountered the same problem (the memory occupation increased until 'Out of Memory' exception).
I was using free version 3.0.10.54040....now I have downloaded 3.5.143 and it works perfectly!!!
The only problem is that I see it's free only for a month,
my firm has no intention to buy the product unfortunately,
so I'll try also to download free version 3.2 hoping it works fine too.
Thank you,
best regards,
Paola

paolagumi
 
Posts: 81
Joined: Tue Apr 21, 2015 11:32 am

Fri Nov 06, 2015 1:48 am

Hello Paola,

Thanks for your reply.
I am glad that your issue has been resolved.
Welcome to write to us again if you have further problems.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Fri Nov 06, 2015 9:48 am

Hello Amy,
with version 3.5.143 the merge works fine,
but the part of my application which creates pdf doesn't work anymore (I used spire doc .0.10.54040)
In the package of spire.pdf 3.5.143 spire.doc is not included...
So i downloaded spire doc 5.5.30 which includes spire.doc. spire.license and spire.pdf dlls.
But when I rebuild the project, it does'nt recognize anymore the spire doc and pdf, but only the license.
For example: it gives me an error on the statement 'Dim Mensile As New Document()', it says 'Type Document is not defined' (which is part of spire.doc)
If I browse the references of spire doc and pdf, I see spire.doc.document....and so on.
Can you help me?
thank you,
Paola

paolagumi
 
Posts: 81
Joined: Tue Apr 21, 2015 11:32 am

Mon Nov 09, 2015 1:35 am

Hello Paola,

Thanks for your inquiry.
If you want Spire.Doc and Spire.Pdf work together in one project, please use Spire.Doc.dll, Spire.Pdf.dll and Spire.License.dll from Spire.Office package.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Mon Nov 09, 2015 7:22 am

Hello Amy,
You mean Spire Platinum 2.12, or Spire Platinum hot fix 2.12.5?
thank you,
Paola

paolagumi
 
Posts: 81
Joined: Tue Apr 21, 2015 11:32 am

Mon Nov 09, 2015 7:29 am

Hi,

Spire.Office Platinum (Hot Fix) Version:2.12.5 is the latest version at present.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Mon Nov 09, 2015 7:54 am

Thank you,
I try immediately!
best regards
Paola

paolagumi
 
Posts: 81
Joined: Tue Apr 21, 2015 11:32 am

Mon Nov 09, 2015 8:15 am

Hi Paola,

You are welcome. Welcome to write us if you have any problems.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF