This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Save to PDF link custom URL

msyea wrote on 2011-06-08:
I would like to implement "Save to PDF" but I have a problem. The page I want to print isn't in the HTTP referrer.

All my pages can be viewed for "Printing" by appending them with "?DESIGN=print" (note this doesn't just change the stylesheet it uses different HTML too). I have print icon on each page that does this. I want to have a PDF icon too but I want to PDF the "Print" view not the "Web" view. I could get users to go to the "Print" view and then the PDF view (to get the correct page to be the referrer) but that is an unnecessary step. My other option is to duplicate the "Print" view and call it "PDF" view but have a bit of JS that does an immediate redirect but again that means more maintenance and is messy.



I hope all the above makes sense. In short my problem could be solved if the comment above was incorrect.

Best regards and thanks for your help.
support wrote on 2011-06-08:
Hello,

we don't plan to support the url field, but you have these two options

1) Use the API.
2) Use media-dependent style sheets and redesign your page like this:
<head>
  <link rel="stylesheet" href="common.css" type="text/css" media="print, screen">
  <link rel="stylesheet" href="screen.css" type="text/css" media="screen">
  <link rel="stylesheet" href="print.css" type="text/css" media="print">
</head>


Add the following rules to your style sheets:
/* screen.css */
.print-only { display: none; }


/* print.css */
.screen-only { display: none; }


Now you can set the print-only class on the elements you want to appear only in PDF and the screen-only class on those you want to appear in the browser only:
<div class="print-only">This will be visible in PDF only.</div>
<div class="screen-only">This will be visible in the browser only.</div>


And finally, insert the following Save to PDF link into your code:
<a href="http://pdfcrowd.com/url_to_pdf/?use_print_media=1">Save to PDF</a>

The use_print_media parameter causes that the converter uses the print.css style sheet when printing your page to PDF.

As a bonus point, if one would like to print your page from the browser, the browser will select the print.css version.
msyea wrote on 2011-06-09:
Thanks. I overlooked the fact that I could do it this way because the print view is a different template too. If there is no option as I suggested I will implement it as you suggested.

Thanks.