Aspose.Pdf.Examples.CSharp.AsposePDF.DocumentConversion.PDFToHTMLFormat.SaveHTMLImageCSS.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            try
            {
                // ExStart:SaveHTMLImageCSS
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion_PDFToHTMLFormat();

                Document doc = new Document(dataDir + "input.pdf");

                // Pay attention that we put non-existing path here : since we use custon resource processing it won't be in use.
                // If You forget implement some of required saving strategies(CustomHtmlSavingStrategy,CustomResourceSavingStrategy,CustomCssSavingStrategy), then saving will return "Path not found" exception
                string outHtmlFile = dataDir + "SaveHTMLImageCSS_out.html";

                // Create HtmlSaveOption with custom saving strategies that will do all the saving job
                // In such approach You can split HTML in pages if You will
                HtmlSaveOptions saveOptions = new HtmlSaveOptions();
                saveOptions.SplitIntoPages = true;

                saveOptions.CustomHtmlSavingStrategy = new HtmlSaveOptions.HtmlPageMarkupSavingStrategy(StrategyOfSavingHtml);
                saveOptions.CustomResourceSavingStrategy = new HtmlSaveOptions.ResourceSavingStrategy(CustomSaveOfFontsAndImages);
                saveOptions.CustomStrategyOfCssUrlCreation = new HtmlSaveOptions.CssUrlMakingStrategy(CssUrlMakingStrategy);
                saveOptions.CustomCssSavingStrategy = new HtmlSaveOptions.CssSavingStrategy(CustomSavingOfCss);

                saveOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.SaveInAllFormats;
                saveOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
                doc.Save(outHtmlFile, saveOptions);

                Console.WriteLine("Done");
                Console.ReadLine();
                // ExEnd:SaveHTMLImageCSS
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        // ExStart:SaveHTMLImageCSSHelper