The CombineFiles method also allows you to combine (append) a list of files, each with their own settings, into a single output file, or a serialized sequence of single page output files in a single call. A common use of this is to print only select pages, or all pages, from each file to build the resulting file.
To allow each file to have their own settings, the list of files passed to the CombineFiles method needs to be a an IList collection of PNConvertFileInfo objects. The PNConvertFileInfo object contains a list of settings that can be applied instead or in addition to the profile settings used when combining.
Only the following converter settings are valid as settings when combining files:
•Ghostscript Converter Options
The path to each file must be a fully qualified path name, relative paths are not accepted. When combining files, the the OutputFolder property on the PNConvertFileInfo object is ignored.
The files are converted in the order in which they are added to the list. A sample list of files to combine is created below; the resulting file will contain all of the pages of the first file, and only the first three pages of the second file.
IList<PNConvertFileInfo> fileInfoList = new List<PNConvertFileInfo>(); IList<PNSetting> filesettings = new List<PNSetting>();
// This file will print all pages and uses only the conversion // settings from the profile - we aren't passing any additional settings. fileInfoList.Add(new PNConvertFileInfo(@"C:\Test\InputFiles\File1.pdf", String.Empty, null));
// This file only prints the first 3 pages, but also shows all markup // in the Word document. filesettings.Add( new PNSetting("PageRange", "1-3")); filesettings.Add( new PNSetting("Microsoft.Word.Document.PrintOut.Item", // converter setting "DocumentAndMarkup") ); fileInfoList.Add(new PNConvertFileInfo(@"C:\Test\InputFiles\File1.doc", String.Empty, filesettings));
|
The code sample below uses the PNConvertFileInfo list created above to append both files into a single multipaged TIFF image containing all the pages of the PDF and the first 3 pages of the Word document with markup displayed.
When combining files, the output directory and final output file name must be provided and the directory must exist before the call is made. The code calls CombineFiles to combine all files in the list and place the final output file in the output folder specified.
The combined file will be created using the conversion settings from the profile TIFF 200dpi OptimizedColor, plus any optional settings supplied for each file.
PNCombineItem resultsItem = null;
|