Merged PDF Size

Merged PDF Size

Forum member · Apr 4, 2012
Hi, i have a pdf file with 6 pages. Three of the pages contain images. The size of the file is 10 mb. I want to merge all of the pages in a new document so the new document should be a copy of the original file. -------- Code ------ Dim Sec As New StandardSecurity Dim PDFDoc As New ceTe.DynamicPDF.Document Sec.AllowCopy = True Sec.AllowEdit = False Sec.AllowPrint = True Sec.AllowUpdateAnnotsAndFields = False PDFDoc.Security = Sec For Each i As Integer In Pages PDFDoc.Append(SourceDocPath, i, 1) Next PDFDoc.Draw(TargetDocFilePath) --------------------------------- The code works and the new file is created with all pages. But the size of the new file is 60 mb. How can I compress the new file to the size of the original? Thanks. Nikolaus Dirks

Re: Merged PDF Size

Support · Apr 4, 2012
Hello Nikolaus, Please try merging the input PDF document by accessing it using file path using DynamicPDF Merger API. Below is the sample code for it. Dim SourceDocPath As String = "F:\temporary\DocumentC.pdf" Dim TargetDocFilePath As String = "C:\MyDocument.pdf" Dim Sec As New StandardSecurity Dim PDFDoc As New MergeDocument() PDFDoc.Append(SourceDocPath) Sec.AllowCopy = True Sec.AllowEdit = False Sec.AllowPrint = True Sec.AllowUpdateAnnotsAndFields = False PDFDoc.Security = Sec PDFDoc.Draw(TargetDocFilePath) Thanks, ceTe Software Support Team.

Re: Merged PDF Size

Forum member · Apr 4, 2012
Hi, thanks for the quick replay. If i append the source document to the new document the size of the new doc is ok, so your code works good in this case. But if i append only single pages(for example 1,3,4,5) to the new document the problem with the size still occures. After appending 4 pages the new doc has a size of 40 mb. Is there a way to reduce the size of the new doc? Nikolaus Dirks

Re: Merged PDF Size

Support · Apr 4, 2012
Hello, If you are loading a PDF document repeatedly in your application to extract the random pages to make a final PDF document then it is suggested to load the input PDF document through PdfDocument class and build an object of PdfDocument class. You can use this PdfDocument object for further process. This will allow you to reuse resources. Below is the sample code for it. Dim pdf As PdfDocument = New PdfDocument("C:\Input.pdf") Dim mergeDocument As MergeDocument = New MergeDocument() For i As Integer = 0 To 5 mergeDocument.Append(pdf, i + 1, 1) Next mergeDocument.Draw("C:\MyDocument.pdf") Thanks, ceTe Software Support Team.

Re: Merged PDF Size

Forum member · Apr 17, 2012
Hi, thanks for the answer. Is it also possible to make a copy of the original document and delete all the pages i don't need? Nikolaus Dirks

Re: Merged PDF Size

Support · Apr 17, 2012
Hello Nikolaus, There is no direct method like Delete in our API using which you can delete the pages from the already existing PDF. You can achieve your requirement by appending the desired pages from the already existing PDF by specifying the start page number and number of pages to be appended. Below is the sample code for it. Dim pdf As PdfDocument = New PdfDocument("C:\Input.pdf") Dim mergeDocument As MergeDocument = New MergeDocument() 'Below code which appends first page of the original documents. 'Similarly you can use start page number and number of pages to be appended to append deired pages. mergeDocument.Append(pdf, 1, 1) mergeDocument.Draw("C:\MyDocument.pdf") Thanks, ceTe Software Support Team.