PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Large file size when split pdf
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2204
Page 1 of 1

Author:  ChrisLoffler [ Wed Oct 31, 2012 3:59 pm ]
Post subject:  Large file size when split pdf

Hello,

When splitting a multi page pdf into single pages, the output file size is very large.
The source input file is about 1.6MB, about 58 pages.
Each output file is about 1.5MB per page.
The source file also contains a few blank pages, which are also output with a filesize of about 1.5MB.

I am using PDFSharp v1.32.2608.0.
I have compiled your code as a release build.
I have also downloaded just the assembly.
I have tried both GDI and WPF.
I am not seeing a difference in file size between debug and release. When compiled as debug, I did see verbose in the pdf header using notepad. Verbose is not there using release.


Code:
Imports System.IO
Imports PdfSharp
Imports PdfSharp.Pdf
Imports PdfSharp.Pdf.IO

    Private Sub TestPDF()
        Dim sFilename As String = "d:\testdoc.pdf"

        Dim inputDocument As PdfDocument
        inputDocument = PdfReader.Open(sFilename, PdfDocumentOpenMode.Import)

        Dim sNameOnly As String = Path.GetFileNameWithoutExtension(sFilename)
        Dim i As Integer = 0

        For i = 0 To 1 'inputDocument.PageCount
            Dim outputDocument As New PdfDocument
            outputDocument.Version = inputDocument.Version

            outputDocument.Info.Title = String.Format("Page {0} of {1}", i, inputDocument.Info.Title)
            outputDocument.Info.Creator = inputDocument.Info.Creator
            outputDocument.AddPage(inputDocument.Pages(i))

            outputDocument.Save(String.Format("d:\{0} - Page {1}_tempfile.pdf", sNameOnly, i))
        Next
    End Sub


Author:  Thomas Hoevel [ Wed Oct 31, 2012 4:05 pm ]
Post subject:  Re: Large file size when split pdf

Hi!

I do not know what makes your undisclosed PDF files so big. I presume it's the fonts that make it so big.

Author:  Trueman [ Mon Jul 06, 2015 1:22 pm ]
Post subject:  Re: Large file size when split pdf

Hi,

I have the same Problem. The way I code is the same as ChrisLofffler did.
My large file has about 2000 pages and its size is about 145MB.
When I split the file into 1000 (2 pages per file) oder 2000 (1 page each file) files, the splitted file each is almost so big (135MB, yes it is Mega Bytes) as the source file.

Do you have any idea where the Problem is ?

Regards,
Tru

Author:  Thomas Hoevel [ Mon Jul 06, 2015 1:37 pm ]
Post subject:  Re: Large file size when split pdf

Hi!

I do not know what makes your undisclosed PDF files so big. I presume it's the fonts that make it so big.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/