3

On the server that my application is being run on, a virtual PDF printer is being installed (don't know much about this yet, except it's from Adobe), and my application needs to use this 'printer' to create PDF's from HTML pages (a GridView mostly), and then redirect the user to the URL of the where the PDF is stored.

I've been looking at the PrintDocument object in System.Drawing.Printing, however I've read that you can't simply feed this a HTML page. What are my choices? The easiest option would be to be able to 'print' a given HTML page (choosing what and what not to print using CSS), but from what I've read this is fairly difficult, so I'm thinking about somehow constructing whatever object PrintDocument needs programatically, if that makes sense.

Any ideas on how I should do this?

7
  • I'm not sure if it's an option for you, but there are commercial server controls that you can purchase that will produce PDF files for you. Telerik's RadControls library is one such example. Commented Mar 15, 2011 at 14:05
  • @Brian: Which one of Telerik's controls will do this? I've looked and haven't located it; granted, I didn't look very hard... Commented Mar 15, 2011 at 14:24
  • @chris: Sorry, my bad, I should have said DevExpress. I have a client that uses both libraries and I suggested the wrong one. Commented Mar 15, 2011 at 14:30
  • Using CSS to change page layout for printing is really easy, ie you can have 2 sets of CSS just take a look at media tag: theblog.ca/variable-textarea However you may have some problem with this Adobe PDF printer, you need to force it somehow to save your file in proper way (autoname) Commented Mar 15, 2011 at 14:31
  • @Brian: Okay, I'll bite. I have a devexpress license as well. ;) Can you point me to which one? BTW, I'm not being a jerk, I really want to know this. I would absolutely love to rip out some of the stuff we did with iTextSharp. Commented Mar 15, 2011 at 14:36

1 Answer 1

1

there are some free/cheap libs for creating pdfs on the fly. I've used itextsharp before and it worked pretty well. Takes a bit of time to get up to speed in how it works but I'd suggest checking it out.

There are also printing services like Neevia DocConverter that will monitor a folder and auto convert whatever you put in the folder to a pdf, jpg, etc. you can set it up so that if you drop a url shortcut in the folder it will render the webpage at that url to pdf. it's a bit more of a pain if you want to do realtime rendering but works excellent for generating mass reports in batches that you want to post up to a website or email later.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.