I have a bunch of PDFs that I'm just trying to open, resize the page, and then save. I'm also hoping that the file sizes will shrink significantly doing so. I am using iTextSharp and the resizing works just fine, but the file size is nearly identical, ever so slightly larger in fact. Here's the function I have now:
Dim reader As New PdfReader(inPDF)
Dim doc As New Document(PageSize.LETTER)
Document.Compress = True
Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream(outPDF, FileMode.Create))
doc.Open()
Dim cb As PdfContentByte = writer.DirectContent
Dim page As PdfImportedPage
For pageNumber As Long = 1 To reader.NumberOfPages
page = writer.GetImportedPage(reader, pageNumber)
cb.AddTemplate(page, PageSize.LETTER.Width / reader.GetPageSize(pageNumber).Width, 0, 0, PageSize.LETTER.Height / reader.GetPageSize(pageNumber).Height, 0, 0)
doc.NewPage()
Next pageNumber
doc.Close()
Does anyone know what I may be missing to actually get the file size down as well?
Thanks.