Protected Sub Button1_Click(sender As Object, e As EventArgs) ' Continue to use the component in a Trial mode when free limit is reached.ĪddHandler ComponentInfo.FreeLimitReached, Sub(sen, ev) ev.FreeLimitReachedAction = FreeLimitReachedAction.ContinueAsTrial ' Set license key to use GemBox.Document in a Free mode.ĬomponentInfo.SetLicense("FREE-LIMITED-KEY") Protected Sub Page_Load(sender As Object, e As EventArgs) The following code is the content of "" file, the page's code behind in VB.NET language. Public override void VerifyRenderingInServerForm(Control control) DocumentModel in PDF format from ASP.NET application.ĭocument.Save(this.Response, "About.pdf") Convert ASPX to PDF by exporting, downloading, HtmlTextWriter htw = new HtmlTextWriter(sw) ĭocumentModel document = new DocumentModel() ĭ(html, LoadOptions.HtmlDefault) Render ASPX page as HTML formatted string. Protected void Button1_Click(object sender, EventArgs e) Continue to use the component in a Trial mode when free limit is reached.ĬomponentInfo.FreeLimitReached += (sen, ev) => ev.FreeLimitReachedAction = FreeLimitReachedAction.ContinueAsTrial Set license key to use GemBox.Document in a Free mode.ĬomponentInfo.SetLicense("FREE-LIMITED-KEY") Protected void Page_Load(object sender, EventArgs e) In The following code is the content of the "" file, the page's code in C# language. This is required to avoid a runtime error when calling the Page.Render method. Notice that the page's EnableEventValidation attribute is set to "false". Lorem ipsum dolor sit amet, consectetur adipiscing elit.ĭuis mattis est quis mauris pulvinar, aliquet mollis dui sagittis. "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit." The following code is the content of the "About.aspx" file. Screenshot of resulting PDF file converted from a ASPX page ASPX code The following screenshot shows the resulting PDF file. Notice that it contains a button control ("Convert ASPX page to PDF") which on click event downloads the PDF file created by converting the page's ASPX code. The following screenshot shows an ASP.NET web page that is converted to PDF. The HTML formatted content is then loaded into a new document, and that document is written, in PDF format, directly to HttpResponse.OutputStream. This is achieved by using a Page.Render method, in the code behind the desired page, to obtain ASPX content in HTML format. The following example demonstrates how to convert an ASP.NET web page (a simple "About.aspx" page) to a PDF format and stream (download) the generated PDF file to the client's browser. In this article, you will learn how to properly convert ASP.NET web pages to HTML and render them to PDF. You can convert any texts, lists, tables, images, forms, and page layouts to look almost identical to the web page in the browser. With GemBox.Document you can convert most content types from ASPX to HTML and render them as PDF files. When you need to convert ASPX web pages to PDF files within your application, the easiest and fastest way is to use a.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |