TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Indhiyan Vaiyapuri
NA
6
14k
Apply custom font family iTextSharp(HTML to PDF)
Nov 10 2018 6:41 AM
I want to generate PDF from HTML using string builder.In that PDF report I have to apply custom fonts.Here is the sample source code which i tried.Can anyone have solutions?.Thanks
StringBuilder sb = new StringBuilder();
sb.Append("New Font Family");
MemoryStream HTMLstream = new MemoryStream(Encoding.UTF8.GetBytes(sb.ToString()));
MemoryStream cssstream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("../Assets/css/pregamereport.css"))));
iTextSharp.text.Rectangle pageSize = new iTextSharp.text.Rectangle(613, 800);
Document pdfDoc = new Document(PageSize.A4, 10f, 20f, 20f, 1f);
fileName = "test";
string ReportLoaction = ConfigurationManager.AppSettings["BoxScoreReport"];
string newStatslocationsite = System.Web.HttpContext.Current.Server.MapPath(ReportLoaction);
if (!Directory.Exists(newStatslocationsite))
{
Directory.CreateDirectory(newStatslocationsite);
}
string finalpath = Path.Combine(newStatslocationsite, fileName);
FileStream createReport = new FileStream(finalpath, FileMode.Create);
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, createReport);
pdfDoc.Open();
XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, HTMLstream, cssstream);
pdfDoc.Close();
Reply
Answers (
4
)
What is the difference between String and string in c#?
log4net in trace level