Exemplo n.º 1
0
        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

        }
Exemplo n.º 2
0
        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();

            // Single input file
            string inputFile = inputPath + "input.docx";

            // Single output file
            string outputFile = outputPath + "output." + outputFormat;

            #region Simple Conversion

            // Converting sample input file to PDF 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, "ConvertToPDF_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, "ConvertToPDF_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, "ConvertToPDF_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, "ConvertToPDF_WithConverterSettings_Custom", ConversionMode.ConvertToSeperateFiles, null, cp);
            #endregion

            #region PDF Encoder Parameters

            // For encoding into PDF files PdfEncoderParams have to be specified
            PDFEncoderSettings pdfEncoderParams = new PDFEncoderSettings();

            // 3 ways of embedding Font information 'FontEmbedType'
            // Gnostice.Documents.PDF.FontEmbedType.None => this will not embed any font information
            // Gnostice.Documents.PDF.FontEmbedType.Full => this will embed the entire font set information
            // Gnostice.Documents.PDF.FontEmbedType.Subset => this will only embed informations about font sets found in the list of files
            pdfEncoderParams.FontEmbedType = Gnostice.Documents.PDF.FontEmbedType.Subset;

            // 3 types of supported PDF versions 'PDFVersion'
            // Gnostice.Documents.PDF.PDFVersion.V1_4
            // Gnostice.Documents.PDF.PDFVersion.V1_5
            // Gnostice.Documents.PDF.PDFVersion.V1_6
            pdfEncoderParams.PDFVersion = Gnostice.Documents.PDF.PDFVersion.V1_4;

            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "Convert_ToPDF_With_EncoderSettings", ConversionMode.ConvertToSeperateFiles, pdfEncoderParams);

            #endregion

        }
Exemplo n.º 3
0
        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();

            // Single input file
            string inputFile = inputPath + "input.docx";

            // Single output file
            string outputFile = outputPath + "output." + outputFormat;

            #region Simple Conversion

            // Converting sample input file to PDF 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, "ConvertToPDF_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, "ConvertToPDF_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, "ConvertToPDF_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, "ConvertToPDF_WithConverterSettings_Custom", ConversionMode.ConvertToSeperateFiles, null, cp);
            #endregion

            #region PDF Encoder Parameters

            // For encoding into PDF files PdfEncoderParams have to be specified
            PDFEncoderSettings pdfEncoderParams = new PDFEncoderSettings();

            // 3 ways of embedding Font information 'FontEmbedType'
            // Gnostice.Documents.PDF.FontEmbedType.None => this will not embed any font information
            // Gnostice.Documents.PDF.FontEmbedType.Full => this will embed the entire font set information
            // Gnostice.Documents.PDF.FontEmbedType.Subset => this will only embed informations about font sets found in the list of files
            pdfEncoderParams.FontEmbedType = Gnostice.Documents.PDF.FontEmbedType.Subset;

            // 3 types of supported PDF versions 'PDFVersion'
            // Gnostice.Documents.PDF.PDFVersion.V1_4
            // Gnostice.Documents.PDF.PDFVersion.V1_5
            // Gnostice.Documents.PDF.PDFVersion.V1_6
            pdfEncoderParams.PDFVersion = Gnostice.Documents.PDF.PDFVersion.V1_4;

            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "Convert_ToPDF_With_EncoderSettings", ConversionMode.ConvertToSeperateFiles, pdfEncoderParams);

            #endregion
        }
Exemplo n.º 4
0
        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
        }