public byte[] GenerateFlyerByteContent(string dealerName, string htmlToConvert) { //// instantiate the HiQPdf HTML to PDF converter var htmlToPdfConverter = new HtmlToPdf(); PDFHelper.ConfigureConverter(htmlToPdfConverter); PdfDocument pdfDocument = htmlToPdfConverter.ConvertHtmlToPdfDocument(htmlToConvert, null); FormatHeader(pdfDocument, dealerName); return(pdfDocument.WriteToMemory()); }
private static void FormatHeader(PdfDocument pdfDocument, string dealershipName, bool showDateTime) { pdfDocument.Header = pdfDocument.CreateHeaderCanvas(pdfDocument.Pages[0].DrawableRectangle.Width, 10); var sysFont = new Font("Times New Roman", 10, GraphicsUnit.Point); //pdfDocument.CreateFont(sysFont); PdfFont pdfFontEmbed = pdfDocument.CreateFont(sysFont, true); if (showDateTime) { pdfDocument.Header.Layout(new PdfText { Text = DateTime.Now.ToShortDateString(), TextFont = pdfFontEmbed, HorizontalAlign = PdfTextHAlign.Right }); } pdfDocument.Header.Layout(new PdfText { Text = dealershipName, TextFont = pdfFontEmbed, HorizontalAlign = PdfTextHAlign.Center }); }
public static void FormatHeader(PdfDocument pdfDocument, string dealershipName) { FormatHeader(pdfDocument, dealershipName, true); }