pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Wadden <glenn_wad...@jhancock.com>
Subject Appending Documents Using PDFMergerUtility Creates Duplicate Resources
Date Mon, 14 May 2012 14:48:32 GMT

I am fairly new to using PDFBOX (using the .net version).  Everything 
seems to be going very well on my project, however whenever we append 
documents using the PDFPDFMergerUtility our merged PDF document is quite 
large and contains duplicate resources.

After the merged PDF is created, when opened and "File -> Save As" is 
selected the following messages are received at the bottom of the screen:

"Consolidating duplicate Fonts"
After saving the PDF it is approximately half the size that it was merged 
out of PDFbox.

Here is a consolidated look at our code:

  Private Function MergePdfFiles(ByVal pdfFileList As List(Of String), _
                                   ByVal outputFileFullName As String) As 
        Dim result As Boolean = False
        Dim fileCount As Integer = pdfFileList.Count
        Dim iPDF As New PDDocument
        Dim oPDF As New PDDocument
        Dim catalogFlag As Boolean = False
        Dim version As Decimal = 1.8

        If fileCount > 1 Then
                'Instantiate an instance of Pdf Merger Utility
                Dim oPDFmerger As PDFMergerUtility = New PDFMergerUtility

                With oPDFmerger
                    'Set output destination
                    'Looping thru the file list and add source to the 
                    For i As Integer = 0 To fileCount - 1 Step 1
                        iPDF = PDDocument.load(pdfFileList(i))
                        oPDFmerger.appendDocument(oPDF, iPDF)
                    Next i
                    'Merge the documents
                    result = True
                End With
            Catch ex As Exception
                WriteToLog("MergePDFFile(" & outputFileFullName & "): " & 
                Return False
            End Try
        End If
        Return result
    End Function

Glenn Wadden


The information contained in this email message and any attachments may be confidential and
legally privileged and is intended for the use of the addressee(s) only.  If you are not an
intended recipient, please: (1) notify me immediately by replying to this message; (2) do
not use, disseminate, distribute or reproduce any part of the message or any attachment; and
(3) destroy all copies of this message and any attachments.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message