I am using the below code to optimize (shrink) existing large PDF files in VS2012 using vb.net:
Dim aspDoc As New Aspose.Pdf.Document(strFN)
Dim optVals As New Aspose.Pdf.Document.OptimizationOptions
optVals.CompressImages = True
optVals.ImageQuality = 22
optVals.RemoveUnusedObjects = True
optVals.RemoveUnusedStreams = True
optVals.LinkDuplcateStreams = True
aspDoc.OptimizeSize = True
Try
aspDoc.OptimizeResources(optVals)
Catch ex As Exception
MsgBox("Error optimizing resources!", MsgBoxStyle.Exclamation, "")
End Try
aspDoc.Save(strFN)
aspDoc.Dispose()
GC.Collect()
aspDoc = Nothing
GC.Collect()
It works just fine on the 1st PDF file, shrinks down from 50+ MB to 5 MB but throws an OUT OF MEMORY exception on any subsequent attempts on other PDF files of the same magnitude during the same run-time session. So only the 1st large PDF file gets optimized without error. See below error:
Image may be NSFW.
Clik here to view.
When I check performance in task manager it shows 5.38 GIG used out of 8 GIG total usuable memory. Why?
Dim aspDoc As New Aspose.Pdf.Document(strFN)
Dim optVals As New Aspose.Pdf.Document.OptimizationOptions
optVals.CompressImages = True
optVals.ImageQuality = 22
optVals.RemoveUnusedObjects = True
optVals.RemoveUnusedStreams = True
optVals.LinkDuplcateStreams = True
aspDoc.OptimizeSize = True
Try
aspDoc.OptimizeResources(optVals)
Catch ex As Exception
MsgBox("Error optimizing resources!", MsgBoxStyle.Exclamation, "")
End Try
aspDoc.Save(strFN)
aspDoc.Dispose()
GC.Collect()
aspDoc = Nothing
GC.Collect()
It works just fine on the 1st PDF file, shrinks down from 50+ MB to 5 MB but throws an OUT OF MEMORY exception on any subsequent attempts on other PDF files of the same magnitude during the same run-time session. So only the 1st large PDF file gets optimized without error. See below error:
Image may be NSFW.
Clik here to view.
When I check performance in task manager it shows 5.38 GIG used out of 8 GIG total usuable memory. Why?