using it.stefanochizzolini.clown.documents;
using it.stefanochizzolini.clown.files;
using it.stefanochizzolini.clown.tools;
using System.Collections.Generic;
namespace it.stefanochizzolini.clown.samples{
/**
<summary>This sample demonstrates how to merge two documents into a unique one.</summary>
*/
public class MergeSample
: ISample
{
public void Run(
SampleLoader loader
)
{
// (boilerplate user choice -- ignore it)
string sourceFilePath = loader.GetPdfFileChoice("Please select source PDF file");
string targetFilePath = loader.GetPdfFileChoice("Please select target PDF file");
// 1. Open the PDF files!
// Source file.
File sourceFile = new File(sourceFilePath);
// Target file.
File targetFile = new File(targetFilePath);
Document targetDocument = targetFile.Document;
// 2. Append the source document's pages to the target document!
new PageManager(targetDocument).Add(sourceFile.Document);
// (boilerplate metadata insertion -- ignore it)
loader.BuildAccessories(targetDocument,this.GetType(),"Merge","concatenating two (or possibly more) documents");
// 3. Serialize the PDF file (again, boilerplate code -- see the SampleLoader class source code)!
loader.Serialize(targetFile,this.GetType().Name);
}
}
}
|