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