Last post Jan 19, 2010 03:13 AM by Qin Dian Tang - MSFT
Member
18 Points
301 Posts
Jan 13, 2010 05:26 PM|joeLA|LINK
Hi,
I exported a form view or repeater into a PDF file.
It looks nice on webpage with signle spacing. But when it exported to the PDF, double or larger space bewtween the lines appears.
How can I reduce the space between the lines to a single space?
Here is my code:
protected void PDFExport() { Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
Repeater1.DataBind();
Repeater1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.LETTER, 12f, 12f, 12f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
All-Star
98048 Points
12424 Posts
Jan 19, 2010 03:13 AM|Qin Dian Tang - MSFT|LINK
Hi joeLA,
Here are some tutorials about how to use iTextSharp class to export to PDF file. Hope they help you:
http://www.codeproject.com/KB/graphics/iTextSharpTutorial.aspx
http://www.codeproject.com/KB/cs/iTextSharpPdfTables.aspx
http://itextsharp.sourceforge.net/tutorial/ch09.html
Thanks,
Member
18 Points
301 Posts
Exported PDF File Format in Formview..?
Jan 13, 2010 05:26 PM|joeLA|LINK
Hi,
I exported a form view or repeater into a PDF file.
It looks nice on webpage with signle spacing. But when it exported to the PDF, double or larger space bewtween the lines appears.
How can I reduce the space between the lines to a single space?
Here is my code:
protected void PDFExport()
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
Repeater1.DataBind();
Repeater1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.LETTER, 12f, 12f, 12f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
All-Star
98048 Points
12424 Posts
Re: Exported PDF File Format in Formview..?
Jan 19, 2010 03:13 AM|Qin Dian Tang - MSFT|LINK
Hi joeLA,
Here are some tutorials about how to use iTextSharp class to export to PDF file. Hope they help you:
http://www.codeproject.com/KB/graphics/iTextSharpTutorial.aspx
http://www.codeproject.com/KB/cs/iTextSharpPdfTables.aspx
http://itextsharp.sourceforge.net/tutorial/ch09.html
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework