You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Glenn Wadden <gl...@jhancock.com> on 2012/05/14 16:48:32 UTC

Appending Documents Using PDFMergerUtility Creates Duplicate Resources

Hi,

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 
Boolean
        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
            Try
                'Instantiate an instance of Pdf Merger Utility
                Dim oPDFmerger As PDFMergerUtility = New PDFMergerUtility

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

Glenn Wadden
glenn.wadden@rogers.com

STATEMENT OF CONFIDENTIALITY

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.

Re: Appending Documents Using PDFMergerUtility Creates Duplicate Resources

Posted by Glenn Wadden <gl...@jhancock.com>.
We are using PDFBox 1.6 built with Ant & IKVM (version 7.0.4335.0).

Glenn Wadden
glenn.wadden@rogers.com



From:
Andreas Lehmkuehler <an...@lehmi.de>
To:
users@pdfbox.apache.org
Date:
05/14/2012 04:29 PM
Subject:
Re: Appending Documents Using PDFMergerUtility Creates Duplicate Resources



Hi,

what version of PDFBox do you use?

BR
Andreas Lehmkühler

Am 14.05.2012 16:48, schrieb Glenn Wadden:
> Hi,
>
> 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
> Boolean
>          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
>              Try
>                  'Instantiate an instance of Pdf Merger Utility
>                  Dim oPDFmerger As PDFMergerUtility = New 
PDFMergerUtility
>
>                  With oPDFmerger
>                      'Set output destination
> oPDFmerger.setDestinationFileName(outputFileFullName)
>                      'Looping thru the file list and add source to the
> merger
>                      For i As Integer = 0 To fileCount - 1 Step 1
>                          iPDF = PDDocument.load(pdfFileList(i))
>                          oPDFmerger.appendDocument(oPDF, iPDF)
>                      Next i
>                      oPDFmerger.mergeDocuments()
>                      'Merge the documents
>                      result = True
>                  End With
>                  oPDF.save(outputFileFullName)
>              Catch ex As Exception
>                  WriteToLog("MergePDFFile("&  outputFileFullName&  "): 
"&
> ex.Message)
>                  Return False
>              End Try
>          End If
>          Return result
>      End Function
>
> Glenn Wadden
> glenn.wadden@rogers.com
>
> STATEMENT OF CONFIDENTIALITY
>
> 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.
>





STATEMENT OF CONFIDENTIALITY

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.

Re: Appending Documents Using PDFMergerUtility Creates Duplicate Resources

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,

what version of PDFBox do you use?

BR
Andreas Lehmkühler

Am 14.05.2012 16:48, schrieb Glenn Wadden:
> Hi,
>
> 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
> Boolean
>          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
>              Try
>                  'Instantiate an instance of Pdf Merger Utility
>                  Dim oPDFmerger As PDFMergerUtility = New PDFMergerUtility
>
>                  With oPDFmerger
>                      'Set output destination
>                      oPDFmerger.setDestinationFileName(outputFileFullName)
>                      'Looping thru the file list and add source to the
> merger
>                      For i As Integer = 0 To fileCount - 1 Step 1
>                          iPDF = PDDocument.load(pdfFileList(i))
>                          oPDFmerger.appendDocument(oPDF, iPDF)
>                      Next i
>                      oPDFmerger.mergeDocuments()
>                      'Merge the documents
>                      result = True
>                  End With
>                  oPDF.save(outputFileFullName)
>              Catch ex As Exception
>                  WriteToLog("MergePDFFile("&  outputFileFullName&  "): "&
> ex.Message)
>                  Return False
>              End Try
>          End If
>          Return result
>      End Function
>
> Glenn Wadden
> glenn.wadden@rogers.com
>
> STATEMENT OF CONFIDENTIALITY
>
> 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.
>