My xml file is as follows:
BBSR
The header part is the header of the document and Tests should be in table format.
Thanks
Nalini
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
FroglegRank #1,020 · 1.9K reputationPosted Sep 18, 2012, 12:50 AM EDT
http://www.c-sharpcorner.com/UploadFile/f2e803/basic-pdf-creation-using-itextsharp-part-i/
Nalini Mishra26 reputationPosted Sep 18, 2012, 2:24 AM EDT
I am new to this situation and appreciate your help.
FroglegRank #1,020 · 1.9K reputationPosted Sep 19, 2012, 12:27 AM EDT
I have not implemented pdf yet
Nalini Mishra26 reputationPosted Sep 20, 2012, 5:31 AM EDT
I am sorry for my late reply.
What ever you did is absolutely fine and the out put should be a pdf. I do appreciate your time and help. Please help me creating the pdf.
Thanks a lot.
Nalini Mishra26 reputationPosted Sep 20, 2012, 5:37 AM EDT
I want to make one more thing clear that creating the pdf in my application is a backend process, so I dont have to display it in any UI and fetch the value from the UI.
Thank you.
rebecca yang18 reputationPosted Sep 13, 2013, 12:48 AM EDT
C#
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Spire.Pdf;
using Spire.Pdf.Graphics;
namespace SendPdfToWebBrowser
{
public partial class WebForm_SendPdf : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
// load a pdf document ,after that ,send it to client browser as an attachment
protected void btnClientSavePdf_Click(object sender,EventArgs e)
{
// initiated an object of Spire.PdfDocument
PdfDocument doc = new PdfDocument();
// Load a pdf file
doc.LoadFromFile(this.Server.MapPath("/sample.pdf"));
// send the pdf document to client browser as an attachment
doc.SaveToHttpResponse("sample.pdf",this.Response, HttpReadType.Save);
}
// Create an pdf document ,then open it in the client browser
protected void btnClientOpenPdf_Click(object sender, EventArgs e)
{
// Initiate an object of Spire.PdfDocument
PdfDocument newDoc = new PdfDocument();
// Add a new page in this newly created pdf file
PdfPageBase page = newDoc.Pages.Add();
string message = "Hello world!" ;
PdfFont font = new PdfFont(PdfFontFamily.Helvetica,13f);
PdfBrush brush = PdfBrushes.Red;
PointF location = new PointF(20, 20);
// Draw a string with designated brush, a font, position in pdf page
page.Canvas.DrawString(message, font, brush, location);
//To open this pdf document in client browser.
newDoc.SaveToHttpResponse("sample.pdf",HttpContext.Current.Response, HttpReadType.Open);
}
}
}
Posted Dec 2, 2013, 11:55 PM EST
Garry Gibson20 reputationPosted May 12, 2014, 11:30 PM EDT
var data = new DataSet(); data.ReadXml("report.xml"); // Create empty document. var document = new DocumentModel(); var section = new Section(document); document.Sections.Add(section); // Create a header content. var headerData = data.Tables["Header"]; var header = new HeaderFooter(document, HeaderFooterType.HeaderDefault); foreach (DataColumn column in headerData.Columns) header.Blocks.Add( new Paragraph(document, new Run(document, column.ColumnName) { CharacterFormat = { Bold = true } }, new SpecialCharacter(document, SpecialCharacterType.Tab), new Run(document, headerData.Rows[0][column].ToString()), new SpecialCharacter(document, SpecialCharacterType.LineBreak))); section.HeadersFooters.Add(header); // Create table content. var tableData = data.Tables["Test"]; var table = new Table(document, tableData.Rows.Count, tableData.Columns.Count, (row, column) => { return new TableCell(document, new Paragraph(document, tableData.Rows[row][column].ToString())); }); section.Blocks.Add(table); // Save as PDF. document.Save("report.pdf", SaveOptions.PdfDefault);Marvin ReidRank #1,963 · 746 reputationPosted Apr 21, 2022, 9:08 AM EDT