Size of file with merged background

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v5)  /  Re: Size of file with merged background

DynamicPDF CoreSuite for .NET (v5) Forum

 Jan 06 2014 10:14 AM
I'm attempting to use a PDF as a background for every page in another file.  The background PDF is 30KB and the variable data file is 232 unique pages with an original file size of 558KB.  When I follow the example provided for backgrounds, I create an output file of 232 pages with a file size of almost 14MB.  If I simply alternate the files (creating 464 pages by alternating the variable data with the background), the file size is 644KB.  If I run the same function but skip adding the variable data overlay, I get 232 pages of background and a very small file size, so the size appears to come from the way the pages of the second file are overlaid on the background.

Other tests have been run, and at about 900 pages, there is an out of memory error.  The production job that will use this function will have several thousand pages, so both the file size and the memory error are problems.

I've tried various things to get the file size down, with no success.  Can you explain why the file size is so large and what to do about it, or suggest another way to apply a background to every page of an existing document?

Here's a portion of my code.  I'm using the .NET library version 5.0.3.35.

Thanks.


        ' Create a PDF Document
        Dim MyDocument As Document = New Document

        ' Create an ImportedPageContents object
        Dim MyContents As Merger.ImportedPageContents = New Merger.ImportedPageContents(isInputFiles(nFILE_NO2).ToString, 1)
        ' Create an ImportedPage for the background
        Dim MyBackground As Merger.ImportedPageData = New Merger.ImportedPageData(MyContents)
        For lPageNo = 1 To lPagesToProcess

            ' Create a Page and add it to the document
            Dim MyPage As Page = New Page

            ' Add the background to the page
            MyPage.Elements.Add(MyBackground)

            Dim MyVariableData As Merger.ImportedPageData = New Merger.ImportedPageData(isInputFiles(nFILE_NO1).ToString, lPageNo)
            MyPage.Elements.Add(MyVariableData)
            MyDocument.Pages.Add(MyPage)

            icProgress.CurrentPage = lPageNo
            MyPage = Nothing
            MyVariableData = Nothing
            Application.DoEvents()
        Next
        ' Save the PDF
        MyDocument.Draw(isOutputFile)
Posted by a ceTe Software moderator
Hello,

Please send over the following details to our support team at:support@cete.com so that they can look into it further.

1.Input (original) PDF documents using which you are importing contents.
2.Background PDF used to add the page background.

Thanks,
ceTe Software Support Team.
Posted by a ceTe Software moderator
Hello,

When adding the same background content to all the pages in a PDF, it is suggested to use the Template class. Create a Template object and the background PDF. Then merge the variable data PDF file using Append method of MergeDocument class. Finally set template to MergeDocument object using Template property. Here is the sample code:

        ' Create an ImportedPageContents object
        Dim MyContents As Merger.ImportedPageContents = New Merger.ImportedPageContents("C:\Temp\Test background.pdf", 1)
        ' Create an ImportedPage for the background
        Dim MyBackground As Merger.ImportedPageData = New Merger.ImportedPageData(MyContents)
        'Create a Template and add imported page data to it.
        Dim template As Template = New Template
        template.Elements.Add(MyBackground)
        'Create a MergeDocument object.
        Dim MyDocument As MergeDocument = New MergeDocument
        'Append the desired PDF choosing required number of pages.
        MyDocument.Append("C:\Temp\RockSpringsTest.pdf", 1, 100)
        'set tamplate to MergeDocument.
        MyDocument.Template = template
       ' Save the PDF
        MyDocument.Draw("C:\Temp\MyDocument.pdf")

Thanks,
ceTe Software Support Team.
Works perfectly.  Thanks for the help.

All times are US Eastern Standard time. The time now is 12:47 AM.