How to implement a "Render this page in PDF"
page 2 of 2
by Markus Schneider
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 21161/ 19
Article Contents:

The Code
Step 2: Render some test pages to PDF

Before you start writing code be sure to test your printable pages by using our Test Form You may also test the html2pdf parameters like landscape, JPG quality, Hyperlinks etc. If you do not want to use the default values be sure to include them in your code.

Step 3: Write the code

There are several possibilities to set up your site for html2pdf.

A) If you simply want to render a standard page (not a special print page) you just need to put the following link to your "render this page to PDF button": The Script will request the referer and render it to PDF.

B) If you want to insert the link in your current code the dynamic link on the "render this page to PDF button" should look something like this: printer friendly full URL of current page&jpeg=60

Please note that the parameter jpeg is like all others (exept url!) optional!

C) If you would like to leave the current code of your pages untouched you may create a simple refer2pdf file and copy it on your server. Here are some examples for such a file:

refer2pdf.aspx using VB.NET

refer2pdf.asp using VBScript

This article was contributed by Markus Schneider and he can be reached at

View Entire Article

User Comments

Title: Questions   
Name: Tony
Date: 2010-02-02 7:40:05 AM
Since you are calling a program on another domain to print a web page, is there not a risk that this program could retain information about the pages that you have printed?

In other words, would it be safe to print any personal or financial information this way without the risk of this being copied or misused.

I also wondered whether it would work if your web page is on an intranet and the site is not accessible from the outside world.
Title: CEO   
Name: Liz
Date: 2005-04-28 8:20:18 AM
In order to create useful PDFs from HTML you first need to prepare the html Templates in a way that they can be printed without errors and malformating. Many state-of-the-art websites got a print button anyway or may be printed as they are without limitations. If your site is missing this feature you may create an additional dynamic template that ignores menus, banner, teasers etc. If your site isn't dynamic you should consider switching to a content management system!

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2023  |  Page Processed at 2023-03-22 9:07:15 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search