Hi
I'm trying to convert some itextsharp stuff to itext7. This itextsharp function just compresses a pdf, replacing the original file as it does so:
Could anyone give me the equivalent in itext7 please? - I've had a go but it doesn't seem to compress the file the way itextsharp does. If I try to use smartmode I run out of memory, and without that the resulting file does not show any improvement in file size.Code:Sub compresspdf(myfile As String) Dim tempfile As String = Form1.tempfolder & "\temp compress.pdf" Dim streamOut As New FileStream(tempfile, FileMode.Create) Dim newDoc As Document = New Document(PageSize.A4) Dim pdfCopy As PdfSmartCopy = New PdfSmartCopy(newDoc, streamOut) pdfCopy.SetMergeFields() newDoc.Open() Dim pdfTemplate As String = myfile Dim pdfReader As New PdfReader(pdfTemplate) pdfCopy.AddDocument(pdfReader) pdfCopy.Close() pdfReader.Close() My.Computer.FileSystem.DeleteFile(myfile) System.IO.File.Move(tempfile, myfile) End Sub
EDIT - sorry, should have mentioned I'm running this on a 400mb pdf provided by a client (it's 4000 pages)
Thanks




Reply With Quote
