When calling the Convert methods from the PEERNET.ConvertUtility library, you have many ways of configuring the output files created.

The easiest method is to pass the name of one of the profiles included with Document Conversion Service into the convert method. You can also pass the full path to a profile on disk that you have created yourself.

A profile is just an XML file that contains the list of conversion settings settings as name/value pairs. Using a profile has the advantage of allowing you to change the conversion settings in the profile on disk without having to recompile your code.

The other two methods are as follows:

Pass Additional Settings with User Settings

Passing a Custom List of Conversion Settings

Pass Additional Settings with User Settings

If you are using a profile to specify your conversion settings you can dynamically modify the profile settings without changing the profile on disk by passing a list of user settings to the convert methods. Settings provided in this list will override matching settings in the profile while new settings will be added to the list of conversion settings for this call only.

This C# code sample demonstrates creating a list of two user settings and passing it to the ConvertFile method. The first additional setting will cause serialized TIFF images to be created instead of multipaged. The second setting is used to control how the Word document is printed; in this case we want to see any document and markup that occurred on the document.

 

IDictionary<String, String> UserSettings = new Dictionary<String, String>();

PNConversionItem resultItem = null;

 

UserSettings.Add("Save;Output File Format", "TIFF Serialized");

UserSettings.Add("Microsoft.Word.Document.PrintOut.Item", "DocumentAndMarkup");

 

// conversion results returned in result item, use it to find files created or errors

resultItem = PNConverter.ConvertFile(@"C:\Input\Memo.doc",

                                     @"C:\Output\",

                                     "ConvertedMemo",

                                     true, // overwrite existing

                                     false, // remove file extension

                                     false, // create log file

                                     "TIFF 200dpi Monochrome",

                                     settings,

                                     String.Empty,

                                     String.Empty,

                                     UserSettings, // custom settings

                                     String.Empty, // remote computer

                                     String.Empty, // use default working folder

                                     String.Empty); 

 

Passing a Custom List of Conversion Settings

You can also configure the output files by passing in a list of conversion settings that you define before you call the convert method. Conversion settings are name/value pairs of settings that define the output files. The same name/value pairs that you would use when creating a profile on disk are used when building these lists of settings.

These settings are commonly used to control what type of output file to create - TIFF, PDF, JPEG, or others, the resolution of the created images, or single-paged or multi-paged output.

Additionally, you can control some aspects of the conversion modules such as having Word documents print with tracking and revisions visible, or having all PowerPoint slides printed with the notes.

The C# code sample below demonstrates calling ConvertFile with a custom list of conversion settings to create a PDF file. The input file C:\Input\Memo.doc will be converted to a PDF file and saved as C:\Output\ConvertedMemo.pdf.

 

IDictionary<String, String> settings = new Dictionary<String, String>();

PNConversionItem resultItem = null;

 

settings.Add("Devmode settings;Resolution", "300");

settings.Add("Save;Output File Format", "Adobe PDF Multipaged");

settings.Add("Save;Append", "0");

settings.Add("Save;Color reduction", "Optimal");

settings.Add("Save;Dithering method", "Halftone");

settings.Add("PDF File Format;PDF Standard", "None");

settings.Add("PDF File Format;Content encoding", "LZW");

settings.Add("PDF File Format;Use ASCII", "0");

settings.Add("PDF File Format;Color compression", "LZW");

settings.Add("PDF File Format;Greyscale compression", "LZW");

settings.Add("PDF File Format;Indexed compression", "LZW");

settings.Add("PDF File Format;BW compression", "Group4");

settings.Add("PDF Security;Use Security", "1");

settings.Add("PDF Security;Encrypt Level", "1");

settings.Add("PDF Security;Can Copy", "1");

settings.Add("PDF Security;Can Print", "1");

settings.Add("PDF Security;Can Change Doc", "0");

settings.Add("PDF Security;Can ChangeOther", "0"):

settings.Add("PDF Security;User Pswd On", "0");

settings.Add("PDF Security;Owner Pswd On", "0");

 

// conversion results returned in result item, use it to find files created or errors

resultItem = PNConverter.ConvertFile(@"C:\Input\Memo.doc",

                                     @"C:\Output\",

                                     "ConvertedMemo",

                                     true, // overwrite existing

                                     false, // remove file extension

                                     false, // create log file

                                     settings,

                                     String.Empty,

                                     String.Empty,

                                     null, // no extra settings

                                     String.Empty, // remote computer

                                     String.Empty, // use default working folder

                                     String.Empty );