private void SetConfig(HtmlToPdfConfig config, ref HtmlToPdf converter) { converter.Options.PdfPageSize = config.PdfPageSize; converter.Options.PdfPageOrientation = config.PdfPageOrientation; converter.Options.WebPageWidth = config.WebPageWidth; converter.Options.WebPageHeight = config.WebPageHeight; converter.Options.MarginBottom = config.MarginBottom; converter.Options.MarginTop = config.MarginTop; converter.Options.MarginLeft = config.MarginLeft; converter.Options.MarginRight = config.MarginRight; converter.Options.AutoFitWidth = config.AutoFitWidth; }
public MemoryStream GeneratePdf(string url, HtmlToPdfConfig config) { MemoryStream result = new MemoryStream(); HtmlToPdf converter = new HtmlToPdf(); SetConfig(config, ref converter); PdfDocument doc = converter.ConvertUrl(url); doc.Save(result); doc.Close(); return(result); }