Results 1 to 2 of 2

Thread: Help with comparing itextsharp with itext7

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2018
    Posts
    159

    Help with comparing itextsharp with itext7

    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:

    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
    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.

    EDIT - sorry, should have mentioned I'm running this on a 400mb pdf provided by a client (it's 4000 pages)

    Thanks
    Last edited by Precision999; Sep 4th, 2023 at 04:24 AM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Sep 2018
    Posts
    159

    Re: Help with comparing itextsharp with itext7

    Well I've done a lot of googling on this and it seems that I need to stick with itextsharp on this one - itext7 just seems to use more memory to achieve the same thing

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width