So far, I have used an evaluation version I downloaded from Amyuni last week to create a single document by appending other multiple documents. While doing this append has worked, there are some issues I have run aross.
Issue 1:
In my tests, I have been creating a new document, then appending all of the existing documents into this one document. While this does work, the document always has a blank page before the begining of the first document appended. I have attempted to remove the first page prior to appending any documents, but still end up with a blank page for page 1 of the combined target document.
I have also tried removing the first page after appending the other documents. While this does work, there appears to be a performance hit for calling the code like this.
document.GetPage(1);
document.CurrentPage.Delete(false);
Is there a better way to approach this?
Issue 2:
The file size of the target combined document can end up MUCH larger than the combined size of the source documents. I see the potential for this to add significant bandwidth overhead when delivering these documents via the httpresponse stream to the client.
For example, when I combine three very simple 1 page PDF files with a size of 38KB into a single document, the resulting size is 165KB rather than close to the 114KB. This was the smallest test I could perform. For a larger test, I combined three larger files.
File 1: 480KB
File 2: 097KB
File 3: 061KB
The result file from PDFCreator.NET was a file size of 3160KB instead of somewhere closer to the approximately 650KB I expected. Is there something I can to to optimize the size.
Issue 3:
I don't have exact numbers on this issue yet, but my perception of appending 3 documents together at this point is that it is not a very speedy process. Is there a speedier approach to combining multiple PDF documents into one that I'm not doing at this point?
Here is the method I'm using to do most of the work for the process.
***************************************************
Code: Select all
private void AppendPdfFiles(string saveTofile)
{
acPDFCreatorLib.Initialize();
acPDFCreatorLib.SetLicenseKey("Visionpace", "Demo");
FileStream sourceFile = null;
FileStream targetFile = null;
Amyuni.PDFCreator.IacDocument target = new Amyuni.PDFCreator.IacDocument();
target.GetPage(1);
target.CurrentPage.Delete(false);
Amyuni.PDFCreator.IacDocument source = null;
foreach (string fileName in FileList)
{
source = new Amyuni.PDFCreator.IacDocument();
sourceFile = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read,
System.IO.FileShare.Read);
try
{
source.Open(sourceFile, "");
}
catch (Exception ex)
{
try
{
source.Open(sourceFile, PdfPassword);
Debug.WriteLine(String.Format("Password required for {0}", fileName));
}
catch (Exception nex)
{
throw nex;
}
}
target.Append(source);
sourceFile.Close();
source.Dispose();
}
if (target.PageCount > 1)
{
targetFile = new System.IO.FileStream(saveTofile, FileMode.Append, FileAccess.Write, FileShare.None);
target.Save(targetFile);
targetFile.Close();
target.Dispose();
FileList.Clear();
}
acPDFCreatorLib.Terminate();
}
***************************************************
thanks,
JE