如何使用pdfsharp将aspx页面导出为pdf [英] how to export aspx page to pdf using pdfsharp

查看:104
本文介绍了如何使用pdfsharp将aspx页面导出为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



是的,我检查了pdfsharp的样本,搜索了很多小时,找到了解决这个非常基本问题的方法。



我已经创建了引用并且能够成功运行hello world程序但是我不知道如何将现有的aspx页面转换为pdf。



如果你有一些代码,那么紧急请给出代码行,因为谷歌的所有链接都已经被我试过了。



提前致谢..





以下是当前代码:



Hi All,

YES, I have checked the samples of pdfsharp and searched for many hours for finding the solution for this very basic issue.

I have created reference and able to run hello world program successfully BUT am NOT able to know how to convert my existing aspx page into pdf.

Its urgent pls give the code lines if you have some as all links through google have already been tried by me.

Thanks in advance..


Below is the current code:

' VB.NET version of 'Hello World'
Private Sub subCreatePDF()
    ' Create a new PDF document
    Dim document As PdfDocument = New PdfDocument
    document.Info.Title = "Created with PDFsharp"

    ' Create an empty page
    Dim page As PdfPage = document.AddPage

    ' Get an XGraphics object for drawing
    Dim gfx As XGraphics = XGraphics.FromPdfPage(page)

    ' Draw crossing lines
    Dim pen As XPen = New XPen(XColor.FromArgb(255, 0, 0))
    gfx.DrawLine(pen, New XPoint(0, 0), New XPoint(page.Width.Point, page.Height.Point))
    gfx.DrawLine(pen, New XPoint(page.Width.Point, 0), New XPoint(0, page.Height.Point))

    ' Draw an ellipse
    gfx.DrawEllipse(pen, 3 * page.Width.Point / 10, 3 * page.Height.Point / 10, 2 * page.Width.Point / 5, 2 * page.Height.Point / 5)

    ' Create a font
    Dim font As XFont = New XFont("Verdana", 20, XFontStyle.Bold)

    ' Draw the text
    gfx.DrawString("Hello, World!", font, XBrushes.Black, _
    New XRect(0, 0, page.Width.Point, page.Height.Point), XStringFormats.Center)


    ' Save the document...
    Dim filename As String = Server.MapPath("~\Documents\Intimation\Hello.pdf") '"H:\HelloWorld.pdf"
    document.Save(filename)

    ' ...and start a viewer.
    Process.Start(filename)

End Sub

推荐答案

网上有很多例子,但这里有一个这应该工作, http:// www。 aspsnippets.com/Articles/Export-ASPNet-Web-Page-with-images-to-PDF-using-ITextsharp.aspx [ ^ ]
There are many examples online but here is one that should work, http://www.aspsnippets.com/Articles/Export-ASPNet-Web-Page-with-images-to-PDF-using-ITextsharp.aspx[^]


这篇关于如何使用pdfsharp将aspx页面导出为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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