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)