using System; using System.IO; using iText.Commons.Utils; using iText.Html2pdf; using iText.Licensing.Base; namespace iText.Samples.Htmlsamples.Chapter07 { /// /// Converts an HTML file with a Base64 image to PDF document. /// public class C07E03_Base64Image { /// /// The path to the resulting PDF file. /// public static readonly String DEST = "results/htmlsamples/ch07/base64.pdf"; /// /// The Base URI of the HTML page. /// public static readonly String BASEURI = "../../../resources/htmlsamples/html/"; /// /// The path to the source HTML file. /// public static readonly String SRC = String.Format("{0}base64.html", BASEURI); /// /// The main method of this example. /// /// no arguments are needed to run this example. public static void Main(String[] args) { using (Stream license = FileUtil.GetInputStreamForFile( Environment.GetEnvironmentVariable("ITEXT7_LICENSEKEY") + "/itextkey-html2pdf_typography.json")) { LicenseKey.LoadLicenseFile(license); } FileInfo file = new FileInfo(DEST); file.Directory.Create(); new C07E03_Base64Image().CreatePdf(BASEURI, SRC, DEST); } /// /// Creates the PDF file. /// /// the base URI /// the path to the source HTML file /// the path to the resulting PDF public void CreatePdf(String baseUri, String src, String dest) { HtmlConverter.ConvertToPdf(new FileInfo(src), new FileInfo(dest)); } } }