Blog

How to Create Short-Cut in VB.net

Posted by Nattudurai Eswaramurthy Blogs | Visual Basic .NET Jun 25, 2012
In this blog I am going to explain about how to create short-cut in VB.net

Here I am showing some example for how to create short-cut in VB.net

Hope this is useful for you. Thus im sharing this article.

HtmlForm form = new HtmlForm();

form.Controls.Add(GridView1);

StringWriter sw = new StringWriter();

HtmlTextWriter hTextWriter = new HtmlTextWriter(sw);

form.Controls[0].RenderControl(hTextWriter);

string html = sw.ToString();

Document Doc = new Document();

 

//PdfWriter.GetInstance

//(Doc, new FileStream(Request.PhysicalApplicationPath

//+ "\\AmitJain.pdf", FileMode.Create));

 

PdfWriter.GetInstance

(Doc, new FileStream(Environment.GetFolderPath

(Environment.SpecialFolder.Desktop)

+ "\\AmitJain.pdf", FileMode.Create));

Doc.Open();

 

Chunk c = new Chunk

("Export GridView to PDF Using iTextSharp \n",

FontFactory.GetFont("Verdana", 15));

Paragraph p = new Paragraph();

p.Alignment = Element.ALIGN_CENTER;

p.Add(c);

Chunk chunk1 = new Chunk

("By Amit Jain, amit_jain_online@yahoo.com \n",

FontFactory.GetFont("Verdana", 8));

Paragraph p1 = new Paragraph();

p1.Alignment = Element.ALIGN_RIGHT;

p1.Add(chunk1);

 

Doc.Add(p);

Doc.Add(p1);

 

System.Xml.XmlTextReader xmlReader =

new System.Xml.XmlTextReader(new StringReader(html));

HtmlParser.Parse(Doc, xmlReader);

 

Doc.Close();

string Path = Environment.GetFolderPath

(Environment.SpecialFolder.Desktop)

+ "\\AmitJain.pdf";

 

ShowPdf(Path);
 

}

 

private void ShowPdf(string strS)

{

Response.ClearContent();

Response.ClearHeaders();

Response.ContentType = "application/pdf";

Response.AddHeader

("Content-Disposition","attachment; filename=" + strS);

Response.TransmitFile(strS);

Response.End();

//Response.WriteFile(strS);

Response.Flush();

Response.Clear();

 

}

post comment
     
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.