I am using PdfSharp to take 3 documents and merge them into 2. The 3 individual documents will print fine but after the merge then they don't print. The printer waits for something but I'm not sure for what.
I've put my code below that I use to combine the files.
A few notes about the code:
1. output is a custom class that just contains some info about the output that I want.
2. htFiles is a hashtable with the PdfDocument objects in it.
When I looked at some of the information about each page I noticed that the mediabox wasn't being set. Could that be a problem?
Code:
PdfDocument pdfOutput = new PdfDocument(outputName);
try
{
pdfOutput.SecuritySettings.PermitFullQualityPrint = true;
pdfOutput.SecuritySettings.PermitModifyDocument = true;
pdfOutput.SecuritySettings.PermitExtractContent = true;
pdfOutput.SecuritySettings.PermitPrint = true;
foreach (OutputPage outputPage in output.Pages)
{
int intTemplateID =GetKey();
int intSequence = GetSequence();
PdfDocument thisPdf =
(PdfDocument)htFiles[intTemplateID];
PdfPage page = thisPdf.Pages[intSequence - 1];
page = pdfOutput.AddPage(page);
}
//Save Pdf
pdfOutput.Save(finalPath + outputName);
}
catch (Exception exc)
{
//Error handling
}
finally
{
pdfOutput.Close();
}
If more information is needed then let me know. I'll try to give as much as possible to fix this. The other alternative is using ABCpdf and I've looked at the documentation for that...