public static void Active() { //string licenseKey = "A635-604D-F82A-680E-A31A-7FEE-F0F9-2EE2"; //Framework.ActivateLicense(licenseKey); string licenseKey = "4F2B-99A8-1A22-C087-214A-95FE-5363-4AA1"; Framework.ActivateLicense(licenseKey); }
static void Main(string[] args) { // Activate Gnostice product Framework.ActivateLicense("4AF4-263D-70A5-F5C8-57E6-045C-ED92-5369"); // Instantiate DocumentConverter DocumentConverter docConverter = new DocumentConverter(); // Subscribe to Error event docConverter.Error += docConverter_Error; // Input Directory string inputPath = @"../../../../../03. Sample Files/"; // Output Directory string outputPath = @"../../../../../04. Output/"; // Output Format string outputFormat = "html"; // List of files as input for the document Converter List <string> inputFiles = Directory.GetFiles(inputPath).ToList(); // Single input file string inputFile = inputPath + "input.docx"; // Single output file string outputFile = outputPath + "output." + outputFormat; #region Simple Conversion // Converting sample input file to HTML format docConverter.ConvertToFile(inputFile, outputFile); #endregion // public List<string> ConvertToFile( // object input, => accepts string (file name) or Stream (file stream) or List<string> or List<Stream> // string outputFileFormat, => expected output file format // string outputDir, => directory in which the output files are to be stored // string baseFileName = "", => name of the output converted file // ConversionMode conversionmode, => ConversionMode.ConvertToSeparateFiles to create a separated file for each converted input file // ConverterSettings converterSettings = null, => specifiy the range of pages to be converted // EncoderSettings encoderSettings = null, => set the information for encoding the document // string inputDocPassword = "" => password for the input document // ); #region One to One Conversion // Converts all // ConversionMode.ConvertToSeparateFiles=>Many to many conversion // Convert list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSeperateFiles docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToHTML_OneToOne_Multiple", ConversionMode.ConvertToSeperateFiles); #endregion #region Convert to single file // ConversionMode.ConverToSingleFile => Convert all the input files and merge it to a single file // Converts list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSingleFile docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToHTML_ManyToOne", ConversionMode.ConvertToSingleFile); #endregion #region Converting file using ConverterSettings // Instantiate ConverterSettings ConverterSettings cp = new ConverterSettings(); // Converter Parameter : PageRange // 4 different types of page ranges // PageRange.All => Converts all pages in input file // PageRange.Even => Converts Pages with even page number // PageRange.Odd => Converts Pages with odd page number // PageRange.Custom => Converts set of pages from input file. ** page range should be specified in CustomPageRange // Convert all even pages in input file cp.PageRange = PageRange.Even; docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToHTML_WithConverterSettings_Even", ConversionMode.ConvertToSeperateFiles, null, cp); // Convert specific pages from input file, say one need to convert 1,3,5,6,7,10 pages from input file cp.PageRange = PageRange.Custom; cp.CustomPageRange = "1,3,5-7,10"; // **PageRange should be set to PageRange.Custom docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToHTML_WithConverterSettings_Custom", ConversionMode.ConvertToSeperateFiles, null, cp); #endregion }
static void Main(string[] args) { // Activate Gnostice product Framework.ActivateLicense("4AF4-263D-70A5-F5C8-57E6-045C-ED92-5369"); // Instantiate DocumentConverter DocumentConverter docConverter = new DocumentConverter(); // Subscribe to Error event docConverter.Error += docConverter_Error; // Input Directory string inputPath = @"../../../../../03. Sample Files/"; // Output Directory string outputPath = @"../../../../../04. Output/"; // List of files as input for the document Converter List <string> inputFiles = Directory.GetFiles(inputPath).ToList(); // Output Format string outputFormat = "tiff"; // Single input file string inputFile = inputPath + "input.docx"; // Single output file string outputFile = outputPath + "output." + outputFormat; #region Simple Conversion // Converting sample input file to TIFF format docConverter.ConvertToFile(inputFile, outputFile); #endregion // public List<string> ConvertToFile( // object input, => accepts string (file name) or Stream (file stream) or List<string> or List<Stream> // string outputFileFormat, => expected output file format // string outputDir, => directory in which the output files are to be stored // string baseFileName = "", => name of the output converted file // ConversionMode conversionmode, => ConversionMode.ConvertToSeparateFiles to create a separated file for each converted input file // ConverterSettings converterSettings = null, => specifiy the range of pages to be converted // EncoderSettings encoderSettings = null, => set the information for encoding the document // string inputDocPassword = "" => password for the input document // ); #region One to One Conversion // Converts all //ConversionMode.ConvertToSeparateFiles=>Many to many conversion //Convert list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSeperateFiles docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToTIFF_OneToOne_Multiple", ConversionMode.ConvertToSeperateFiles); #endregion #region Convert to single file //ConversionMode.ConverToSingleFile => Convert all the input files and merge it to a single file //Converts list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSingleFile docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToTIFF_ManyToOne", ConversionMode.ConvertToSingleFile); #endregion #region Converting file using ConverterSettings // Instantiate ConverterSettings ConverterSettings cp = new ConverterSettings(); // Converter Parameter : PageRange // 4 different types of page ranges // PageRange.All => Converts all pages in input file // PageRange.Even => Converts Pages with even page number // PageRange.Odd => Converts Pages with odd page number // PageRange.Custom => Converts set of pages from input file. ** page range should be specified in CustomPageRange // Convert all odd pages in input file cp.PageRange = PageRange.Odd; docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToTIFF_WithConverterSettings_Even", ConversionMode.ConvertToSeperateFiles, null, cp); // Convert specific pages from input file, say one need to convert 1,3,5,6,7,10 pages from input file cp.PageRange = PageRange.Custom; cp.CustomPageRange = "1,3,5-7,10"; // **PageRange should be set to PageRange.Custom docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToTIFF_WithConverterSettings_Custom", ConversionMode.ConvertToSeperateFiles, null, cp); #endregion #region TIFF Encoder settings // TIFF encoder formats TIFFEncoderSettings tiffEncoderFormats = new TIFFEncoderSettings(); // Compression Type // 4 types // TiffCompressionType.None => No Compression // TiffCompressionType.CCIT3 => Group 3 compression // TiffCompressionType.CCIT4 => Group 4 compression // TiffCompressionType.Rle => Run length compression // TiffCompressionType.Lzw => Lempel–Ziv–Welch lossless data compression tiffEncoderFormats.CompressionType = TiffCompressionType.None; // Page Scaling // 2 types of page scaling // PageScaling.None => No page scaling // PageScalling.UseRenderingResolution => scaling to the rendering resolution tiffEncoderFormats.PageScalling = PageScalling.None; // Rendering Settings // The compositing mode CompositingMode determines whether pixels from a source image overwrite or are combined with background pixels. // 2 compositing modes // System.Drawing.Drawing2D.CompositingMode.SourceOver => Specifies that when a color is rendered, it is blended with the background color. The blend is determined by the alpha component of the color being rendered. // System.Drawing.Drawing2d.Compositing.SourceCopy => Specifies that when a color is rendered, it overwrites the background color. tiffEncoderFormats.RenderingSettings.Image.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy; //The composition quality CompositingQuality sets the rendering quality of composited images drawn // 6 compositing quality types // CompositingQuality.AssumeLinear => Assume linear values // CompositingQuality.Default => Default quality // CompositingQuality.GammaCorrected => Use Gamma correction // CompositingQuality.HighQuality => High quality low speed compositing // CompositingQuality.HighSpeed => High speed low quality compositing // CompositingQuality.Invalid => Invalid quality tiffEncoderFormats.RenderingSettings.Image.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.Default; // The Interpolation mode sets the interpolation mode associated with this image // 9 Interpolation modes // InterpolationMode.Bicubic => Specifies bicubic interpolation. No prefiltering is done. This mode is not suitable for shrinking an image below 25 percent of its original size. // InterpolationMode.Bilinear => Specifies bilinear interpolation. No prefiltering is done. This mode is not suitable for shrinking an image below 50 percent of its original size. // InterpolationMode.Default => Specifies default mode. // InterpolationMode.High => Specifies high quality interpolation. // InterpolationMode.HighQualityBicubic => Specifies high-quality, bicubic interpolation. Prefiltering is performed to ensure high-quality shrinking. This mode produces the highest quality transformed images. // InterpolationMode.HighQualityBilinear => Specifies high-quality, bilinear interpolation. Prefiltering is performed to ensure high-quality shrinking. // InterpolationMode.Invalid => Equivalent to the Invalid element of the QualityMode enumeration. // InterpolationMode.Low => Specifies low quality interpolation. // InterpolationMode.NearestNeighbor => Specifies nearest-neighbor interpolation. tiffEncoderFormats.RenderingSettings.Image.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; // The pixel offset mode sets a value specifying how pixels are offset during rendering of this image // 6 pixel offset modes // PixelOffsetMode.Half => Specifies that pixels are offset by -.5 units, both horizontally and vertically, for high speed antialiasing. // PixelOffsetMode.Default => Specifies the default mode // PixelOffsetMode.None => Specifies no pixel offset // PixelOffsetMode.HighQuality => High quality low speed rendering // PixelOffsetMode.HighSpeed => High speed low quality rendenring // PixelOffsetMode.Invalid => Specifies an invalid mode tiffEncoderFormats.RenderingSettings.Image.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Default; // The smoothing mode specifies whether lines, curves, and the edges of filled areas use smoothing (also called antialiasing) // 6 Line Smoothening modes for line art // System.Drawing.Drawing2D.SmoothingMode.AntiAlias => Specifies antialiased rendering. // System.Drawing.Drawing2D.SmoothingMode.Default => Specifies no antialiasing. // System.Drawing.Drawing2D.SmoothingMode.HighQuality => Specifies antialiased rendering. // System.Drawing.Drawing2D.SmoothingMode.HighSpeed => Specifies no antialiasing. // System.Drawing.Drawing2D.SmoothingMode.Invalid => Specifies an invalid mode. // System.Drawing.Drawing2D.SmoothingMode.None => Specifies no antialiasing. tiffEncoderFormats.RenderingSettings.LineArt.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; // Text Contarst tiffEncoderFormats.RenderingSettings.Text.TextContrast = 5; // Text Rendering Hint // 6 types of text rendering hints // System.Drawing.Text.TextRenderingHint.SystemDefault => Each character is drawn using its glyph bitmap, with the system default rendering hint. The text will be drawn using whatever font-smoothing settings the user has selected for the system. // System.Drawing.Text.TextRenderingHint.AntiAlias => Each character is drawn using its antialiased glyph bitmap without hinting. Better quality due to antialiasing. Stem width differences may be noticeable because hinting is turned off. // System.Drawing.Text.TextRenderingHint.AntiAliasGridFit => Each character is drawn using its antialiased glyph bitmap with hinting. Much better quality due to antialiasing, but at a higher performance cost. // System.Drawing.Text.TextRenderingHint.ClearTypeGridFit => Each character is drawn using its glyph ClearType bitmap with hinting. The highest quality setting. Used to take advantage of ClearType font features. // System.Drawing.Text.TextRenderingHint.SingleBitPerPixelPerGridFit => Each character is drawn using its glyph bitmap. Hinting is used to improve character appearance on stems and curvature. // System.Drawing.Text.TextRenderingHint.SingleBitPerPixel => Each character is drawn using its glyph bitmap. Hinting is not used. tiffEncoderFormats.RenderingSettings.Text.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; // Rendering Settings resolution tiffEncoderFormats.RenderingSettings.Resolution.DPI = 96f; tiffEncoderFormats.RenderingSettings.Resolution.DpiX = 96f; tiffEncoderFormats.RenderingSettings.Resolution.DpiY = 96f; // Resolution Mode // 3 types of resolution modes // ResolutionMode.UseSource => use source resolution // ResolutionMode.UseDevice => use device resolution // ResolutionMode.UseSpecifiedDPI => use DPI specified in pngEncoderFormats.RenderingSettings.Resolution.DPI tiffEncoderFormats.RenderingSettings.Resolution.ResolutionMode = ResolutionMode.UseSource; // Resolution Settings resolution tiffEncoderFormats.ResolutionSettings.DPI = 96f; tiffEncoderFormats.ResolutionSettings.DpiX = 96f; tiffEncoderFormats.ResolutionSettings.DpiY = 96f; // Resolution Settings Resolution Mode // 3 types of resolution modes // ResolutionMode.UseSource => use source resolution // ResolutionMode.UseDevice => use device resolution // ResolutionMode.UseSpecifiedDPI => use DPI specified in pngEncoderFormats.RenderingSettings.Resolution.DPI tiffEncoderFormats.ResolutionSettings.ResolutionMode = ResolutionMode.UseSource; // Multipage TIFF conversion // MultiPage => convert and combine each page in a multipage file into a single file tiffEncoderFormats.MultiPage = true; docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToTIFF_WithEncoderSettings_into_MultiPageTIFFFile", ConversionMode.ConvertToSeperateFiles, tiffEncoderFormats); //Singlepage TIFF conversion //Converts a file containing multiple pages into separate files for each page tiffEncoderFormats.MultiPage = false; docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToTIFF_WithEncoderSettings_into_SinglePageTIFFFile", ConversionMode.ConvertToSeperateFiles, tiffEncoderFormats); #endregion }
static void Main(string[] args) { // Activate Gnostice product Framework.ActivateLicense("4AF4-263D-70A5-F5C8-57E6-045C-ED92-5369"); // Instantiate DocumentConverter DocumentConverter docConverter = new DocumentConverter(); // Subscribe to Error event docConverter.Error += docConverter_Error; // Input Directory string inputPath = @"../../../../../03. Sample Files/"; // Output Directory string outputPath = @"../../../../../04. Output/"; // Output Format string outputFormat = "txt"; // List of files as input for the document Converter List <string> inputFiles = Directory.GetFiles(inputPath).ToList(); // Single input file string inputFile = inputPath + "input.docx"; // Single output file string outputFile = outputPath + "output." + outputFormat; #region Simple Conversion // Converting sample input file to TXT format docConverter.ConvertToFile(inputFile, outputFile); #endregion // public List<string> ConvertToFile( // object input, => accepts string (file name) or Stream (file stream) or List<string> or List<Stream> // string outputFileFormat, => expected output file format // string outputDir, => directory in which the output files are to be stored // string baseFileName = "", => name of the output converted file // ConversionMode conversionmode, => ConversionMode.ConvertToSeparateFiles to create a separated file for each converted input file // ConverterSettings converterSettings = null, => specifiy the range of pages to be converted // EncoderSettings encoderSettings = null, => set the information for encoding the document // string inputDocPassword = "" => password for the input document // ); #region One to One Conversion // Converts all //ConversionMode.ConvertToSeparateFiles=>Many to many conversion //Convert list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSeperateFiles docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToTXT_OneToOne_Multiple", ConversionMode.ConvertToSeperateFiles); #endregion #region Convert to single file //ConversionMode.ConverToSingleFile => Convert all the input files and merge it to a single file //Converts list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSingleFile docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToTXT_ManyToOne", ConversionMode.ConvertToSingleFile); #endregion #region Converting file using ConverterSettings // Instantiate ConverterSettings ConverterSettings cp = new ConverterSettings(); // Converter Parameter : PageRange // 4 different types of page ranges // PageRange.All => Converts all pages in input file // PageRange.Even => Converts Pages with even page number // PageRange.Odd => Converts Pages with odd page number // PageRange.Custom => Converts set of pages from input file. ** page range should be specified in CustomPageRange // Convert all even pages in input file cp.PageRange = PageRange.Even; docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToTXT_WithConverterSettings_Even", ConversionMode.ConvertToSeperateFiles, null, cp); // Convert specific pages from input file, say one needs to convert pages 1,4,8,9,10,11,12 from input file cp.PageRange = PageRange.Custom; cp.CustomPageRange = "1,4,8-12"; // **PageRange should be set to PageRange.Custom docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToTXT_WithConverterSettings_Custom", ConversionMode.ConvertToSeperateFiles, null, cp); #endregion #region TXT Encoder Parameters // For encoding file into TXT textEncoderParams have to be specified TextEncoderSettings txtEncoderParams = new TextEncoderSettings(); txtEncoderParams.ByteOrderMarkBytes = new byte[0]; // Types of file Encoding Files 'FileEncoding' // FileEncoding.ISO_8859_1=> encoding files in ISO 8859-1 // FileEncoding.US_ASCII=>Encoding files in US ASCII // FileEncoding.UTF_16BE=> Encoding files in UTF 16BE // FileEncoding.UTF_16LE=> Encoding files in UTF 16LE // FileEncoding.UTF_8=> Encoding files in UTF 8 (default file encoding) txtEncoderParams.FileEncoding = FileEncoding.UTF_8; // 6 members of TextFormatter // TextFormatter.BreakLines=> break point at every line // TextFormatter.BreakPages=>break point at every page // TextFormatter.BreakParagraphs=>break point at every paragraph // TextFormatter.CustomPageBreak=>to enable cutom break point // TextFormatter.CustomPageBreakText=>set the custom break point // TextFormatter.FILE_SEPARATOR_CHAR=>set the file separator character // TextFormatter.PageBreakText=>set the page break text // For setting break point to every line txtEncoderParams.TextFormatter.CustomPageBreak = true; txtEncoderParams.TextFormatter.CustomPageBreakText = "<<Page Break>>"; // txtEncoderParams.UseByteOrderMark=>to use byte order mark txtEncoderParams.UseByteOrderMark = true; docConverter.ConvertToFile(inputFile, "txt", outputPath, "ConvertToTXT_WithEncoderSettings", ConversionMode.ConvertToSeperateFiles, txtEncoderParams, cp); #endregion }
static void Main(string[] args) { // Activate Gnostice product Framework.ActivateLicense("4AF4-263D-70A5-F5C8-57E6-045C-ED92-5369"); // Instantiate DocumentConverter DocumentConverter docConverter = new DocumentConverter(); // Subscribe to Error event docConverter.Error += docConverter_Error; // Input Directory string inputPath = @"../../../../../03. Sample Files/"; // Output Directory string outputPath = @"../../../../../04. Output/"; // Output Format string outputFormat = "pdf"; // List of files as input for the document Converter List <string> inputFiles = Directory.GetFiles(inputPath).ToList(); // public List<string> ConvertToFile( // object input, => accepts string (file name) or Stream (file stream) or List<string> or List<Stream> // string outputFileFormat, => expected output file format // string outputDir, => directory in which the output files are to be stored // string baseFileName = "", => name of the output converted file // ConversionMode conversionmode, => ConversionMode.ConvertToSeparateFiles to create a separated file for each converted input file // ConverterSettings converterSettings = null, => specifiy the range of pages to be converted // EncoderSettings encoderSettings = null, => set the information for encoding the document // string inputDocPassword = "" => password for the input document // ); #region PDF Encoder Settings // For encoding into PDF portfolios files PdfEncoderParams have to be specified PDFEncoderSettings pdfEncoderParams = new PDFEncoderSettings(); // 3 conditions of creating PDF portfolio // PortfolioCreationMode.Always => Always creates a portfolio // PortfolioCreationMode.Off => Does not create a portfolio // PortfolioCreationMode.OnlyWhenAttachmentsExist => Creates a portfolio only when there is more than one document // PortfolioCreationMode.WhenInputIsPortfolio => creates a portfolio when the input is a portfolio pdfEncoderParams.PDFPortfolioSettings.PortfolioCreationMode = PortfolioCreationMode.Always; // 3 views of the PDF portfolio // PortfolioLayoutMode.Details => Shows the details of the various files in the portfolio // PortfolioLayoutMode.Hide => Hides the details of the various files in the portfolio // PortfolioLayoutMode.Tile => Dispays the attached documents in the form of tiles pdfEncoderParams.PDFPortfolioSettings.PortfolioLayoutMode = PortfolioLayoutMode.Tile; #endregion #region Covert first file and attach remaining in their original forms // ConversionMode.ConvertFirstFileAndAttachRestAsOriginal => Converts first file and attaches remaining as originals docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToPDFPortfolio_ConvertFirstFileAndAttachRestAsOriginal", ConversionMode.CreateNewFileAndAttachAllAsOriginal, pdfEncoderParams); #endregion #region Attach all originals //ConversionMode.ConverToSingleFile =>creates a new file and attaches all files in their original form without converting any file docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToPDFPortfolio_CreateNewFileAndAttachAllAsOriginal", ConversionMode.CreateNewFileAndAttachAllAsOriginal, pdfEncoderParams); #endregion #region Converting file using ConverterSettings // Instantiate ConverterSettings ConverterSettings cp = new ConverterSettings(); // Converter Parameter : PageRange // 4 different types of page ranges // PageRange.All => Converts all pages in first input file // PageRange.Even => Converts Pages with even page number in the first input file // PageRange.Odd => Converts Pages with odd page number in the first input file // PageRange.Custom => Converts set of pages from first input file. ** page range should be specified in CustomPageRange // Convert all even pages in first input file cp.PageRange = PageRange.Even; docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToPDFPortfolio_WithConverterSettings_Even", ConversionMode.ConvertFirstFileAndAttachRestAsOriginal, pdfEncoderParams, cp); // Convert specific pages from input file, say one need to convert 1,3,5,6,7,10 pages from input file cp.PageRange = PageRange.Custom; cp.CustomPageRange = "1,3,5-7,10"; // **PageRange should be set to PageRange.Custom docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToPDFPortfolio_WithConverterSettings_Custom", ConversionMode.ConvertFirstFileAndAttachRestAsOriginal, pdfEncoderParams, cp); #endregion }