本文介绍了使用带有另存为选项的vb.net将HTml导出到Pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

这是我用vb.net将html导出为pdf的代码。

pdf文件保存在给定的默认路径中。但我想导出保存文件为选项

,以便最终用户可以将文件保存在所需的位置。



代码:

Hi All,
This is the code that i have used to export html to pdf using vb.net.
the pdf file gets saved in the default path given. But i want to export with Save File As option
so that the end user could save the file in desired location.

CODE:

Str.Clear()
                Str.Append("<table cellspacing=1 cellpadding=0 border=0 width=100% align=center class='tblrpt'>")
                Str.Append("<tr class='bbtdwht'><td align='center' colspan='3'><b>No Record(s) Found  </b></td></tr>")
                Str.Append("</table>")
                Dim StrContent As String
                StrContent = Str.ToString
                Dim doc As New Document(PageSize.LETTER, 80, 50, 30, 65)
                Dim fsNew As New StringReader(StrContent)
                Dim document As New Document(PageSize.A4, 80, 50, 30, 65)
                Using fs As New FileStream(Request.ApplicationPath & "/Print/Pf" & Session("User_id") & ".pdf", FileMode.Create)
                    PdfWriter.GetInstance(document, fs)
                    Using stringReader As New StringReader(StrContent)
                        Dim parsedList = html.simpleparser.HTMLWorker.ParseToList(stringReader, Nothing)
                        document.Open()
                        For Each item As Object In parsedList
                            document.Add(DirectCast(item, IElement))
                        Next
                        document.Close()
                    End Using
                End Using

推荐答案


这篇关于使用带有另存为选项的vb.net将HTml导出到Pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 08:25