Question : itextSharp doubles in size

Please find the attached code snippet. The code works but the files when extracted are about double the original size.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
Public Shared Sub ExtractPdf(ByVal sourcePdf As String, ByVal pageNumbersToExtract As Integer(), ByVal outPdf As String)
        Dim reader As iTextSharp.text.pdf.PdfReader = Nothing
        Dim doc As iTextSharp.text.Document = Nothing
        Dim pdfCpy As iTextSharp.text.pdf.PdfCopy = Nothing
        Dim page As iTextSharp.text.pdf.PdfImportedPage = Nothing
        Try
            iTextSharp.text.Document.Compress = True
            reader = New iTextSharp.text.pdf.PdfReader(sourcePdf)
            doc = New iTextSharp.text.Document(reader.GetPageSizeWithRotation(1))
            'doc.Compress = iTextSharp.text.Document.Compress = True
            pdfCpy = New iTextSharp.text.pdf.PdfCopy(doc, New IO.FileStream(outPdf, IO.FileMode.Create))
            doc.Open()
            
            For Each pageNum As Integer In pageNumbersToExtract
                page = pdfCpy.GetImportedPage(reader, pageNum)
                pdfCpy.AddPage(page)
            Next
            Form1.setPageSize(reader.NumberOfPages)

            pdfCpy.CompressionLevel = 100
            pdfCpy.SetFullCompression()

            doc.Close()
            reader.Close()
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

Answer : itextSharp doubles in size

An alternative:
http://www.a-pdf.com/split/ (Paid solution)

Or why not try cutepdf and print the pages you want as a separate document?
Random Solutions  
 
programming4us programming4us