views:

20

answers:

2

I am somewhat new to web development, so I'm not sure how "stupid" this question is, but I couldn't find much when searching, so I wanted to ask.

I am creating a page that, when a user presses an Export button, it exports a snapshot of the site as a PDF. The PDF library takes a URL. That works well. However, I want this page inside a larger site. When I print, however, I don't want the larger site to be printed. Is there a way to supply an "internal" HTML address so that my web page can still be accessed. What should I look at to do something like this?

Thanks.

A: 

I'm wondering if by "larger site" you mean the template surrounding your content. Is that true? If so, a common approach is to provide a parameter that can be added to your request, like print=1, which would suppress the outer template when delivering your content.

jheddings
+2  A: 

The best way to "hide" the rest of the page when the user prints a web page is to create a print stylesheet and include it in the page header like this:

<link rel="stylesheet" type="text/css" href="print.css" media="print">

Then simply hide the elements of the page that you don't want printing in your print.css file.

jaywon
Yeah, that is a nice approach... And more portable than my `print=1`. The only drawback is that the printing library has to honor the CSS. Still, +1.
jheddings