/// <summary> /// Adds the HTM lto PDF. /// </summary> /// <param name="docPDF">The doc PDF.</param> /// <param name="strBTOC">The STR BTOC.</param> internal void AddHTMLtoPDF(Document docPDF, String strBTOC, string strContext, bool blnIsTOC) { if (blnIsTOC) { strbaseURL = strContext; htmlToPdfElement = new HtmlToPdfElement(Convert.ToString(strBTOC), strbaseURL); pdfPage = docPDF.InsertPage(1, PageSize.A4, new Margins(40), PageOrientation.Portrait); //docPDF.AddPage(PageSize.A4, new Margins(10, 10, 0, 0), PageOrientation.Portrait); pdfPage.AddElement(htmlToPdfElement); docPDF.Pages.Add(pdfPage); } else { strbaseURL = strContext; htmlToPdfElement = new HtmlToPdfElement(Convert.ToString(strBTOC), strbaseURL); pdfPage = docPDF.AddPage(PageSize.A4, new Margins(40), PageOrientation.Portrait); pdfPage.AddElement(htmlToPdfElement); docPDF.Pages.Add(pdfPage); } }
/// <summary> /// Adds the book title. /// </summary> /// <param name="docPDF">The doc PDF.</param> /// <param name="strBooktitle">The STR booktitle.</param> internal void AddBookTitle(Document docPDF, XPathDocument xmlDocumentCriteria, Boolean IsTOCApplicable, string type) { strbookHeader = string.Empty; strbookHeader = "DIGITAL WELL BOOK _____________________________________________________"; try { pdfBLL = new PdfBLL(); strbookTitle = pdfBLL.GetAttributeBookInfo(xmlDocumentCriteria, "BookName"); if (IsTOCApplicable) { pdfPage = docPDF.Pages[0]; } else { docPDF.InsertPage(0, PageSize.A4, new Margins(), PageOrientation.Portrait); pdfPage = docPDF.Pages[0]; } #region Header for Book Title Page //Generate Text // Create a Bold .NET font of 10 points System.Drawing.Font fntVerdanaHeadaer = new System.Drawing.Font("Verdana", 15, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); // Create the PDF fonts based on the .NET true type fonts PdfFont newfntVerdanaHeadaer = docPDF.AddFont(fntVerdanaHeadaer); // Add Title elements to the document TextElement PageTitleVerdanaHeadaer = new TextElement(3, 20, strbookHeader, newfntVerdanaHeadaer); PageTitleVerdanaHeadaer.TextAlign = HorizontalTextAlign.Left; pdfPage.AddElement(PageTitleVerdanaHeadaer); #endregion //Generate Text #region bOOK tITLE System.Drawing.Font ttfFontBold = new System.Drawing.Font("Verdana", 30, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); // Create the PDF fonts based on the .NET true type fonts PdfFont newVerdanaFontBold = docPDF.AddFont(ttfFontBold); // Add Title elements to the document TextElement TypeTitle = new TextElement(3, 300, strbookTitle, newVerdanaFontBold); TypeTitle.TextAlign = HorizontalTextAlign.Center; AddElementResult addTitle = pdfPage.AddElement(TypeTitle); #endregion ///Generate Text for Book Owner #region bOOK oWNER System.Drawing.Font fntVerdanaBold = new System.Drawing.Font("Verdana", 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); // Create the PDF fonts based on the .NET true type fonts PdfFont newfntVerdanaBold = docPDF.AddFont(fntVerdanaBold); //Add Book Owner to Page TextElement TypeVerdanaBold = new TextElement(3, addTitle.EndPageBounds.Bottom + 5, "Book Owner - " + pdfBLL.GetAttributeBookInfo(xmlDocumentCriteria, "BookOwner"), newfntVerdanaBold); TypeVerdanaBold.TextAlign = HorizontalTextAlign.Center; AddElementResult addOwner = pdfPage.AddElement(TypeVerdanaBold); #endregion #region Published Date System.Drawing.Font ttfFont = new System.Drawing.Font("Verdana", 10, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); // Create the PDF fonts based on the .NET true type fonts PdfFont newVerdanaFont = docPDF.AddFont(ttfFont); TextElement TypeVerdanaDate; if (type.Equals("pdf")) { TypeVerdanaDate = new TextElement(3, addOwner.EndPageBounds.Bottom + 5, "Published date: " + DateTime.Now.ToString(DATEFORMAT), newVerdanaFont); } else { TypeVerdanaDate = new TextElement(3, addOwner.EndPageBounds.Bottom + 5, "Date: " + DateTime.Now.ToString(DATEFORMAT), newVerdanaFont); } TypeVerdanaDate.TextAlign = HorizontalTextAlign.Center; pdfPage.AddElement(TypeVerdanaDate); #endregion } finally { } }