如何在vb.net中将文件保存为PDF formate? [英] how I can Save file in PDF formate in vb.net?

查看:434
本文介绍了如何在vb.net中将文件保存为PDF formate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Public Sub ExportGridToExcel(ByRef grdGridView As GridView, ByVal fileName As String)
Response.Clear()
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.xls", fileName))
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim strWr As New StringWriter()
Dim HtmlWr As New HtmlTextWriter(strWr)
grdGridView.RenderControl(HtmlWr)
Response.Write(strWr.ToString)
Response.End()
End Sub


请告诉我如何转换为pdf格式


please tell me how i can convert in pdf format

推荐答案

Hai这是在vb.net中使用itextsharp.dll创建pdf文件的示例. 昏暗的文档作为新文档(iTextSharp.text.PageSize.LETTER,10,10,42,35)
PdfWriter = PdfWriter.GetInstance(doc,New FileStream("D:\ Temporary \ sample.pdf",FileMode.Create)的昏暗作家 doc.Open()


昏暗的段落作为新段落(这是我的第一段")
昏暗的法尔语作为新短语(这是我的第一句话")
昏暗的块_作为新块(这是我的第一个块")

doc.Add(para)
doc.Add(pharse)
doc.Add(chunk_)

doc.Close()
Hai here is an example to create a pdf file using itextsharp.dll in vb.net
Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35)
Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream("D:\Temporary\sample.pdf", FileMode.Create))
doc.Open()


Dim para As New Paragraph("This is my first paragraph")
Dim pharse As New Phrase("This is my first phrase")
Dim chunk_ As New Chunk("This is my first chunk")

doc.Add(para)
doc.Add(pharse)
doc.Add(chunk_)

doc.Close()


下载Dll iTextSharp
来自http://www.codeproject.com/KB/cs/iTextSharpPdfTables/iTextSharpPdfTables.zip
然后连接您的应用程序资源.
Download the Dll iTextSharp
from http://www.codeproject.com/KB/cs/iTextSharpPdfTables/iTextSharpPdfTables.zip
and then connect your application resource.


您需要将其通过Excel到PDF转换器:
You would need to pass it through an Excel to PDF converter: Google[^] can help


这篇关于如何在vb.net中将文件保存为PDF formate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆