How to convert HTML page with graphic objects to PDF?


Article from our customer

Hi to All! Our company is engaged in geological exploration for new mineral deposits! In our daily work the one of important thing is getting of fresh topographic maps, which we are using for exploration!

Our company works closely with the Google Maps service! To all the cards were “at hand” at the employee, our Technical Department has decided to convert the maps from Google Maps to PDF format. This option allows us to have fresh cards even if no internet! To convert a variety of maps to PDF we are using the component PDF Vision.Net from the company SautinSoft.

Now our employees can always be guided by fresh cards varying degrees of zoom!

This is a code snippet to convert HTML page (with maps.google.com) to PDF format:

using System.IO;
using SautinSoft.PdfVision;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            ConvertUrlToPdfFile();
        }
        public static void ConvertUrlToPdfFile()
        {
            PdfVision v = new PdfVision();
            string inpHtml = @"https://developers.google.com/maps/documentation/javascript/examples/map-geolocation";
            string outPdf = Path.GetFullPath("Result.pdf");

            HtmlToPdfOptions opt = new HtmlToPdfOptions()
            {
                ChromiumBaseDirectory = new DirectoryInfo(@"..\..\..\").FullName
            };
            v.ConvertHtmlToPdf(inpHtml, outPdf, opt);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outPdf) { UseShellExecute = true });
        }
    }
}

Если вам нужен пример кода или у вас есть вопрос: напишите нам по адресу support@sautinsoft.ru или спросите в онлайн-чате (правый нижний угол этой страницы) или используйте форму ниже:



Вопросы и предложения всегда приветствуются!

Мы разрабатываем компоненты .Net с 2002 года. Мы знаем форматы PDF, DOCX, RTF, HTML, XLSX и Images. Если вам нужна помощь в создании, изменении или преобразовании документов в различных форматах, мы можем вам помочь. Мы напишем для вас любой пример кода абсолютно бесплатно.