public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new TxtLoadOptions
            {
                LeadingSpacesOptions           = TxtLeadingSpacesOptions.ConvertToIndent,
                DetectNumberingWithWhitespaces = true
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new TxtLoadOptions
            {
                LeadingSpacesOptions           = TxtLeadingSpacesOptions.ConvertToIndent,
                DetectNumberingWithWhitespaces = true
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_TXT, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nTxt document converted successfully. \nCheck output in {0}", outputFolder);
        }
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
            {
                Password = "******"
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
            {
                Password = "******"
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_DOCX_WITH_PASSWORD, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions
                {
                    PageNumber = 2,
                    PagesCount = 1,
                    Rotate     = Rotation.On180,
                    Dpi        = 300,
                    Width      = 1024,
                    Height     = 768
                };
                converter.Convert(outputFile, options);
            }
            Console.WriteLine("\nPassword protected document converted successfully. \nCheck output in {0}", outputFolder);
        }
示例#3
0
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.html");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
            {
                Password = "******"
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
            {
                Password = "******"
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_DOCX_WITH_PASSWORD, getLoadOptions))
            {
                MarkupConvertOptions options = new MarkupConvertOptions
                {
                    PageNumber             = 2,
                    FixedLayout            = true,
                    PagesCount             = 1,
                    FixedLayoutShowBorders = false
                };
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nPassword protected document converted successfully. \nCheck output in {0}", outputFolder);
        }
示例#4
0
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new SpreadsheetLoadOptions
            {
                SkipEmptyRowsAndColumns = true,
                OnePagePerSheet         = true
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new SpreadsheetLoadOptions
            {
                SkipEmptyRowsAndColumns = true,
                OnePagePerSheet         = true
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_XLSX, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nSpreadsheet document converted successfully. \nCheck output in {0}", outputFolder);
        }
        /// <summary>
        /// This example demonstrates how to implement custom cache when rendering document.
        /// </summary>
        public static void Run()
        {
            string outputDirectory = Constants.GetOutputDirectoryPath();

            RedisCache cache = new RedisCache("sample_");

            Contracts.Func <ConverterSettings> settingsFactory = () => new ConverterSettings
            {
                Cache = cache
            };

            using (Converter converter = new Converter(Constants.SAMPLE_PDF, settingsFactory))
            {
                PdfConvertOptions options = new PdfConvertOptions();

                Stopwatch stopWatch = Stopwatch.StartNew();
                converter.Convert("converted.pdf", options);
                stopWatch.Stop();

                Console.WriteLine("Time taken on first call to Convert method {0} (ms).", stopWatch.ElapsedMilliseconds);

                stopWatch.Restart();
                converter.Convert("converted-1.pdf", options);
                stopWatch.Stop();

                Console.WriteLine("Time taken on second call to Convert method {0} (ms).", stopWatch.ElapsedMilliseconds);
            }

            Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
        }
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new CadLoadOptions
            {
                Width  = 1920,
                Height = 1080
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new CadLoadOptions
            {
                Width  = 1920,
                Height = 1080
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_DWG_WITH_LAYOUTS_AND_LAYERS, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }


            Console.WriteLine("\nCad document converted successfully. \nCheck output in {0}", outputFolder);
        }
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.xls");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
            {
                Password = "******"
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
            {
                Password = "******"
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_DOCX_WITH_PASSWORD, getLoadOptions))
            {
                SpreadsheetConvertOptions options = new SpreadsheetConvertOptions
                {
                    PageNumber = 2,
                    PagesCount = 1,
                    Format     = SpreadsheetFileType.Xls,
                    Zoom       = 150
                };
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nPassword protected document converted successfully. \nCheck output in {0}", outputFolder);
        }
示例#8
0
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.xlsx");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new XmlLoadOptions
            {
                UseAsDataSource = true
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new XmlLoadOptions
            {
                UseAsDataSource = true
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_XML_DATASOURCE, () => new XmlLoadOptions
            {
                UseAsDataSource = true
            }))
            {
                SpreadsheetConvertOptions options = new SpreadsheetConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nXml document converted successfully. \nCheck output in {0}", outputFolder);
        }
示例#9
0
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new EmailLoadOptions
            {
                ConvertOwned   = false,
                TimeZoneOffset = TimeSpan.FromHours(5)
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new EmailLoadOptions
            {
                ConvertOwned   = false,
                TimeZoneOffset = TimeSpan.FromHours(5)
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_EML, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nEmail document converted successfully. \nCheck output in {0}", outputFolder);
        }
示例#10
0
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new CsvLoadOptions
            {
                ConvertDateTimeData = true,
                ConvertNumericData  = true
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new CsvLoadOptions
            {
                ConvertDateTimeData = true,
                ConvertNumericData  = true
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_CSV, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nCsv document converted successfully. \nCheck output in {0}", outputFolder);
        }
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <ConverterSettings> settingsFactory = () => new ConverterSettings
            {
                Listener = new ConverterListener()
            };

            Func <LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
            {
                Password = "******"
            };
#else
            Contracts.Func <ConverterSettings> settingsFactory = () => new ConverterSettings
            {
                Listener = new ConverterListener()
            };

            Contracts.Func <LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
            {
                Password = "******"
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_DOCX_WITH_PASSWORD, getLoadOptions, settingsFactory))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nPassword protected document converted successfully. \nCheck output in {0}", outputFolder);
        }
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new PresentationLoadOptions
            {
                DefaultFont     = "Helvetica",
                FontSubstitutes = new List <FontSubstitute>
                {
                    FontSubstitute.Create("Tahoma", "Arial"),
                    FontSubstitute.Create("Times New Roman", "Arial"),
                }
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new PresentationLoadOptions
            {
                DefaultFont     = "Helvetica",
                FontSubstitutes = new List <FontSubstitute>
                {
                    FontSubstitute.Create("Tahoma", "Arial"),
                    FontSubstitute.Create("Times New Roman", "Arial"),
                }
            };
#endif
            using (Converter converter = new Converter(Constants.PPTX_WITH_NOTES, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nPresentation document converted successfully. \nCheck output in {0}", outputFolder);
        }
示例#13
0
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new TxtLoadOptions
            {
                Encoding = Encoding.GetEncoding("shift_jis")
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new TxtLoadOptions
            {
                Encoding = Encoding.GetEncoding("shift_jis")
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_TXT_SHIFT_JS_ENCODED, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nTxt document converted successfully. \nCheck output in {0}", outputFolder);
        }
示例#14
0
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
            {
                HideWordTrackedChanges = true
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new WordProcessingLoadOptions
            {
                HideWordTrackedChanges = true
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_DOCX_WITH_TRACKED_CHANGES, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nWordProcessing document converted successfully. \nCheck output in {0}", outputFolder);
        }
示例#15
0
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new EmailLoadOptions
            {
                ConvertOwner = true,
                ConvertOwned = true,
                // convert email itself and the attachments
                Depth = 2
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new EmailLoadOptions
            {
                ConvertOwner = true,
                ConvertOwned = true,
                // convert email itself and the attachments
                Depth = 2
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_EML_WITH_ATTACHMENT, getLoadOptions))
            {
                int index = 1;
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(() =>
                {
                    string fileName = index == 1 ? "converted.pdf" : $"converted-attachment-{index - 1}.pdf";
                    index++;
                    string outputFile = Path.Combine(outputFolder, fileName);
                    return(new FileStream(outputFile, FileMode.Create));
                }, options);
            }

            Console.WriteLine("\nEmail document converted successfully. \nCheck output in {0}", outputFolder);
        }
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.docx");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new PdfLoadOptions
            {
                FlattenAllFields = true
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new PdfLoadOptions
            {
                FlattenAllFields = true
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_PDF, getLoadOptions))
            {
                WordProcessingConvertOptions options = new WordProcessingConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nPdf document converted successfully. \nCheck output in {0}", outputFolder);
        }
示例#17
0
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new EmailLoadOptions
            {
                ConvertOwned            = false,
                DisplayHeader           = false,
                DisplayFromEmailAddress = false,
                DisplayToEmailAddress   = false,
                DisplayEmailAddress     = false,
                DisplayCcEmailAddress   = false,
                DisplayBccEmailAddress  = false
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new EmailLoadOptions
            {
                ConvertOwned            = false,
                DisplayHeader           = false,
                DisplayFromEmailAddress = false,
                DisplayToEmailAddress   = false,
                DisplayEmailAddress     = false,
                DisplayCcEmailAddress   = false,
                DisplayBccEmailAddress  = false
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_MSG, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nEmail document converted successfully. \nCheck output in {0}", outputFolder);
        }
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new EmailLoadOptions
            {
                ConvertOwned = false,
                FieldTextMap = new Dictionary <EmailField, string>
                {
                    { EmailField.Subject, "Gegenstand" },
                    { EmailField.From, "Von" },
                    { EmailField.Attachments, "Anhänge" }
                }
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new EmailLoadOptions
            {
                ConvertOwned = false,
                FieldTextMap = new Dictionary <EmailField, string>
                {
                    { EmailField.Subject, "Gegenstand" },
                    { EmailField.From, "Von" },
                    { EmailField.Attachments, "Anhänge" }
                }
            };
#endif
            using (Converter converter = new Converter(Constants.SAMPLE_EML, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nEmail document converted successfully. \nCheck output in {0}", outputFolder);
        }
        public static void Run()
        {
            string outputFolder = Constants.GetOutputDirectoryPath();
            string outputFile   = Path.Combine(outputFolder, "converted.pdf");

#if NETCOREAPP
            Func <LoadOptions> getLoadOptions = () => new PresentationLoadOptions
            {
                HideComments = true
            };
#else
            Contracts.Func <LoadOptions> getLoadOptions = () => new PresentationLoadOptions
            {
                HideComments = true
            };
#endif
            using (Converter converter = new Converter(Constants.PPTX_WITH_NOTES, getLoadOptions))
            {
                PdfConvertOptions options = new PdfConvertOptions();
                converter.Convert(outputFile, options);
            }

            Console.WriteLine("\nPresentation document converted successfully. \nCheck output in {0}", outputFolder);
        }