nandakishoreroyal
private void HTMLtoPDF()
{
try
{
string sFilePath = "C:/Users/NandaKishore.K/Desktop/";
FileStream fs = File.Create(sFilePath + "SamplePDF.pdf");
Document document = new Document();
BaseFont bfR = iTextSharp.text.pdf.BaseFont.CreateFont(BaseFont.TIMES_ROMAN, iTextSharp.text.pdf.BaseFont.CP1257, iTextSharp.text.pdf.BaseFont.EMBEDDED);
PdfWriter writer = PdfWriter.GetInstance(document, fs);
PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
document.Add(jpg);
//iTextSharp.text.Font HeaderOne = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 16f, iTextSharp.text.Font.BOLD);
//Font Chronicle = FontFactory.GetFont("Chronicle Display Black");
//Chronicle.Size = 16;
//Chronicle.IsBold();
BaseFont bfChronicleFont = BaseFont.CreateFont("C:\\inetpub\\wwwroot\\Practice\\Practice\\Fonts\\ChronicleDisp-Black.otf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font ChronicleFont = new Font(bfChronicleFont, 16f);
BaseFont bfBrandonFont = BaseFont.CreateFont("C:\\inetpub\\wwwroot\\Practice\\Practice\\Fonts\\Brandon_reg.otf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font BrandonFont = new Font(bfBrandonFont, 14f, Font.NORMAL);
PdfPTable table1 = new PdfPTable(1);
PdfPCell pdfCell;
pdfCell = new PdfPCell(new Phrase("BELLEVUE SQUARE", ChronicleFont));
pdfCell.Border = 0;
pdfCell.PaddingTop = 40;
pdfCell.PaddingLeft = 100;
table1.AddCell(pdfCell);
pdfCell = new PdfPCell(new Phrase("Use our west entrance on two.", BrandonFont));
pdfCell.Border = 0;
pdfCell.PaddingTop = 10;
pdfCell.PaddingLeft = 100;
table1.AddCell(pdfCell);
pdfCell = new PdfPCell(new Phrase("Thursday, November 29, 7:30 p.m.", BrandonFont));
pdfCell.Border = 0;
pdfCell.PaddingLeft = 100;
table1.AddCell(pdfCell);
pdfCell = new PdfPCell(new Phrase(string.Empty));
pdfCell.Border = 0;
pdfCell.FixedHeight = 60;
table1.AddCell(pdfCell);
document.Add(table1);
PdfPTable table2 = new PdfPTable(5);
PdfPCell pdfCell2;
pdfCell2 = new PdfPCell(new Phrase("Name:", BrandonFont));
pdfCell2.PaddingLeft = 100;
pdfCell2.Border = 0;
pdfCell2.Colspan = 3;
table2.AddCell(pdfCell2);
pdfCell2 = new PdfPCell(new Phrase("Name", BrandonFont));
pdfCell2.Border = 0;
table2.AddCell(pdfCell2);
pdfCell2 = new PdfPCell(new Phrase(string.Empty));
pdfCell2.Border = 0;
table2.AddCell(pdfCell2);
pdfCell2 = new PdfPCell(new Phrase("Total Number of Guests:", BrandonFont));
pdfCell2.PaddingLeft = 110;
pdfCell2.PaddingTop = 15;
pdfCell2.Colspan = 3;
pdfCell2.Border = 0;
table2.AddCell(pdfCell2);
pdfCell2 = new PdfPCell(new Phrase("Name", BrandonFont));
pdfCell2.PaddingTop = 15;
pdfCell2.Border = 0;
table2.AddCell(pdfCell2);
pdfCell2 = new PdfPCell(new Phrase(string.Empty));
pdfCell2.Border = 0;
table2.AddCell(pdfCell2);
pdfCell2 = new PdfPCell(new Phrase("Confirmation Number:", BrandonFont));
pdfCell2.PaddingTop = 15;
pdfCell2.Colspan = 3;
pdfCell2.PaddingLeft = 100;
pdfCell2.Border = 0;
table2.AddCell(pdfCell2);
pdfCell2 = new PdfPCell(new Phrase("Name", BrandonFont));
pdfCell2.PaddingTop = 15;
pdfCell2.Border = 0;
table2.AddCell(pdfCell2);
pdfCell2 = new PdfPCell(new Phrase(string.Empty));
pdfCell2.Border = 0;
table2.AddCell(pdfCell2);
pdfCell2 = new PdfPCell(new Phrase(string.Empty));
pdfCell2.Colspan = 5;
pdfCell2.Border = 0;
pdfCell2.FixedHeight = 80;
table2.AddCell(pdfCell2);
document.Add(table2);
document.Close();
fs.Close();
Response.AddHeader("Content-Disposition", "attachment;filename=SamplePDF.pdf");
Response.ContentType = "application/pdf";
Response.TransmitFile("C:\\Users\\NandaKishore.K\\Desktop\\SamplePDF.pdf");
Response.End();
}
catch (Exception ex)
{
}
}
Member 10513529
охраняемых недействительными btnPdf_Click(объект отправителя, EventArgs в электронной)
{
Ответ.ContentType = "приложение/pdf";
Ответ.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, ложные);
Шрифт ChronicleFont = новый шрифт(bfTimes, 26f);
Ответ.Кэш.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = новый StringWriter();
HtmlTextWriter hw = новый HtmlTextWriter(sw);
Tbldata.RenderControl(hw);
StringReader sr = новый StringReader(sw.Метод toString());
Документ pdfDoc = новый документ(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = новый HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, ответ.Выходной поток);
pdfDoc.Открыть();
htmlparser.Синтаксический анализ(СР);
pdfDoc.Рядом();
Ответ.Запись(pdfDoc);
Ответ.Конец();
}
вот мой код я сделал изменения bt не получаю никакой разницы в выводе
nandakishoreroyal
удалить документ pdfDoc = новый документ(PageSize.A4, 10f, 10f, 100f, 0f);
и поместите документ pdfDoc = новый документ();