Link Search Menu Expand Document

Download and Process file - C#

PDF To HTML SDK sample in C# demonstrating ‘Download and Process file’

using System;
using System.Diagnostics;
using System.IO;
using Bytescout.PDF2HTML;

namespace ExtractHTMLFromPage
    class Program
        static void Main(string[] args)
            // Create Bytescout.PDF2HTML.HTMLExtractor instance
            HTMLExtractor extractor = new HTMLExtractor();
            extractor.RegistrationName = "demo";
            extractor.RegistrationKey = "demo";

            // Set HTML with CSS extraction mode
            extractor.ExtractionMode = HTMLExtractionMode.HTMLWithCSS;

            // Input file Url
            var inputUrl = @"";

            // Get Input Stream
            var inpStream = GetStreamFromUrl(inputUrl);

            // Load sample PDF document

            // Convert 1-st page to HTML and save it to file
            extractor.SaveHtmlPageToFile(0, "output.html");

            // Cleanup

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("output.html");
            processStartInfo.UseShellExecute = true;

        /// <summary>
        /// Get stream from Url
        /// </summary>
        private static Stream GetStreamFromUrl(string url)
            byte[] oData = null;

            using (var wc = new System.Net.WebClient())
                oData = wc.DownloadData(url);

            return new MemoryStream(oData);


Download Source Code (.zip)

Return to the previous page Explore PDF To HTML SDK