/    Sign up×
Community /Pin to ProfileBookmark

"Printable Page" that can be emailed

You know, “click here for printable version” – but I want a downloadable document made from the same HTML content that a web page displays. Is there any utility out there, for example, that will convert HTML to a PDF, with valid hyperlinks?

The background on this, FWIW:
I am building a single-source communications database that includes communication content and other data, such as a relatively complex contacts DB, that is used for automating various tasks. All my content data is stored on a MySQL server, and I have ODBC-linked tables in a MS Access front end for manipulating data at the desktop level.

We manage the web data through this front end. Right now I have an Access report that we print to a PDF, to use for the downloadable file that goes with the web page. We do use some HTML tags in the content, and I have a VBA routine that strips out the tags for printing the Access report. But I don’t like the limitations of the Access report. The biggest issue right now is that I can’t figure out a way to make hyperlinks work in the PDF, from the Access report.

So I’m fishing for new ideas about how to offer a downloadable version of a (simple) web page, where the conversion will preserve hyperlinks…

to post a comment
PHP

19 Comments(s)

Copy linkTweet thisAlerts:
@strBeanauthorMar 24.2007 — Anybody know if Adobe Acrobat can make a PDF out of an HTML document, with active hyperlinks? Haven't bought that program yet...
Copy linkTweet thisAlerts:
@bokehMar 24.2007 — You know, "click here for printable version" - but I want a downloadable document made from the same HTML content that a web page displays. Is there any utility out there, for example, that will convert HTML to a PDF, with valid hyperlinks?[/QUOTE]That doesn't make any sense at all. In my opinion the point of a pdf is it is for printing, and printed media doesn't have hyperlinks.
Copy linkTweet thisAlerts:
@strBeanauthorMar 24.2007 — Thanks for the distinction. I don't care what kind of document it is, it just needs to be a file type that anyone can read.

I have a web forum that is restricted to a small group of execs. They need a [b]portable[/b] version of the thread that they can either print and hand to their boards of directors or email to them. (They get to share pieces of content without sharing their password to the forum.) If one of their board members is viewing it on a monitor, they expect hyperlinks to work.

A MS Word document is "for printing" but hyperlinks in it work. People expect that.

Meanwhile, back at the ranch, I have discovered that the cheap PDF writer that I have does interpret a string with 'http' in it and tries to make a hyperlink. It's doing this with the Access report that I have with the same data behind it as the web page. But the trouble is, the PDF writer gets confused and truncates the link about half the time. It is trying to interpret where the link should start and end without the benefit of tags. So what I have, it turns out, is not a document without active hyperlinks, but a document with BAD hyperlinks...

This should better explain my predicament. Thanks, bokeh
Copy linkTweet thisAlerts:
@felgallMar 24.2007 — PDFs are not just for printable media. The lastest version of Acrobat can import entire web sites and even the Javascript will still run on the pages since PDF format now supports Javascript.

The purely printable version of a PDF is called PostScript.
Copy linkTweet thisAlerts:
@bokehMar 24.2007 — PDFs are not just for printable media.[/QUOTE]Well if that's what you believe maybe you should rush off to convert your site from HTML to PDF.
Copy linkTweet thisAlerts:
@strBeanauthorMar 24.2007 — Hey thanks, felgall, I think you understand what I'm trying to do. If Acrobat can make a portable document out of HTML, there is probably much demand for that. Especially if one doesn't want to Microsoft everything. I'll check the price.

Well if that's what you believe maybe you should rush off to convert your site from HTML to PDF.[/QUOTE]
Are you having a bad day? PDF can't do server-side processing, but there could be a use for this concept. Do you have a different solution for my problem?
Copy linkTweet thisAlerts:
@aussie_girlMar 25.2007 — There's a PDF class for PHP called EZPDF I have used it, and you can put links into it. You do need to read the documentation to tweak it to want you want

http://www.ros.co.nz/pdf/
Copy linkTweet thisAlerts:
@felgallMar 25.2007 — There are a number of different PHP classes available for generating PDFs. I don't know which of any of them support all of the features that you can put into PDFs using Acrobat though but then you probably wont need all the features such as stamping, highlighting, commenting, Javascript etc anyway.

PDF has two advantages over HTML in that you can stop people accessing your page source and you can embed the fonts you want to use into the page itself.

PDFs are intended both for use online and for printing.
Copy linkTweet thisAlerts:
@bokehMar 25.2007 — PDF: Unfit for Human Consumption

According to Flanders: [I]Anyone who has ever dealt with a two-year old has probably yelled, "Chairs are for sitting!" at one time or other. Apparently, this two-year old mentality exists in corporations because too many people forget that "PDF is for printing" and are incorrectly using the Adobe Acrobat PDF format as an HTML tool.



Just as you don't use a chainsaw to create a woodworking joint, you don't use PDF (or Flash or whatever) when what you want can be created using HTML. If you're using PDF because the people you work with are too stupid to learn how to use HTML, get new people. There are lots of unemployed folks who can do the job.



PDF can be a wonderful tool if you don't want people to actually read what you've written. If I were a government agency and I was legally obligated to provide information I didn't want to provide, I'd create some 250Mb PDF file — and make sure people knew it was going to take 9 hours, 41 minutes and 17 seconds to download.[/I]
Copy linkTweet thisAlerts:
@1andywMar 25.2007 — One approach:

http://www.mhanp.org/mclaughlin25.php

View the print preview.

If you like that, view the CSS for 'media print' rules.

Andy
Copy linkTweet thisAlerts:
@strBeanauthorMar 25.2007 — One approach:

http://www.mhanp.org/mclaughlin25.php

View the print preview.

If you like that, view the CSS for 'media print' rules.

Andy[/QUOTE]

That's an elegant printing solution to give the user who visits the page. I'm looking for something that can be downloaded and emailed.

Steven and Aussie: That is very good news - a PHP class. Almost too good to be true...

thanks very much for your time and effort,
Copy linkTweet thisAlerts:
@strBeanauthorMar 25.2007 — Hey Aussie

or Steven --

I have put the ezpdf class in a directory and am trying to test it like this:
[code=php]
$path = 'usrwwwuserswashing3privatedocuments'.$_GET["dest"];
require('/usr/www/users/washing3/cgi-bin/pdf/class.ezpdf.php');
$pdf = new Cezpdf();
$pdf->ezText($print); // I have loaded HTML into $print, to see what ezPDF does...
$pdfcode = $pdf->ezOutput();

$fp = fopen($path,'wb');

fwrite($fp,$pdfcode);
fclose($fp);
[/code]


...and I'm getting an "unexpected T_string" error at the line with fopen() in it. the only other class I have downloaded and used is phpmailer. I don't remember if I had to do something to my php.ini file ... ?

The odd bit is that fopen() is just basic PHP, isn't it?

Can you see a goof in this code? Have I left out some important step?
Copy linkTweet thisAlerts:
@felgallMar 25.2007 — "PDF is for printing" [/QUOTE]

PostScript is for printing - PDF is for online use AND printing.

If printing were all PDF were intended for then it would be just PostScript and would not have all of the online add-ons such as form handling and Javascript. Take out all the facilities for online processing and all you have left is PostScript which is what Adobe started with before they started creating PDF.

There are lots of things that can be done with PDF that can't be done with HTML such as ensuring that the page has a fixed layout using a fixed font, stopping the content from being able to be edited. etc.

Saying that you should be using HTML instead of PDF for all your online pages is like saying that you should travel everywhere by car and that boats and planes should not be used for travel. There are times where PDF is a far more appropriate format to use than HTML and many instances where you can use PDF online where you can't use HTML because PDF can be used anywhere online while HTML doesn't work too well in most situations beyond the web. Those web pages where it is better to use PDF than HTML are those intended for printing rather than online use. PDF can also be used to create ebooks that can be both read online and printed as well as being able to be easily emailed. If you have documents to send to someone electronically then PDF is the appropriate format to use.

While PDFs can be printed their primary purpose its for online documents. Of course replacing all your HTML pages with PDFs would be like throwing your car away and always using a plane to travel everywhere but trying to use HTML where a PDF is more appropriate would be like trying to drive around the world in under a week.
Copy linkTweet thisAlerts:
@felgallMar 25.2007 — Hey Aussie

or Steven --

I have put the ezpdf class in a directory and am trying to test it like this:
[code=php]
$path = 'usrwwwuserswashing3privatedocuments'.$_GET["dest"];
require('/usr/www/users/washing3/cgi-bin/pdf/class.ezpdf.php');
$pdf = new Cezpdf();
$pdf->ezText($print); // I have loaded HTML into $print, to see what ezPDF does...
$pdfcode = $pdf->ezOutput();

$fp = fopen($path,'wb');

fwrite($fp,$pdfcode);
fclose($fp);
[/code]


...and I'm getting an "unexpected T_string" error at the line with fopen() in it. the only other class I have downloaded and used is phpmailer. I don't remember if I had to do something to my php.ini file ... ?

The odd bit is that fopen() is just basic PHP, isn't it?

Can you see a goof in this code? Have I left out some important step?[/QUOTE]


Your path has the slashes going the wrong way and so they are escaping the following characters.
Copy linkTweet thisAlerts:
@strBeanauthorMar 25.2007 — I just saw that, too. But I don't trust the line numbers in the error messages. Probably still a number of problems lurking there.
Copy linkTweet thisAlerts:
@strBeanauthorMar 25.2007 — Thanks, everybody, for a lively conversation about portable files!

Okay, after I ferreted out the typos, I did get the code to write a file to a directory, but the file was unreadable. I guess I was hoping that the ezText method of the class would just take my raw HTML and make PDF code out of it - silly. I imagine I need to study this class and learn how to set all the properties in order to get what I want.

I got the impression from your first post that the latest Acrobat will take HTML and display it properly - does this ezPDF class have a method for that, too?

And finally, I want to return to Mr. bokeh's point. I have been playing around with making sure my output HTML string (that I am trying to pass to ezPDF, without success) is debugged, and now what I have is a PHP script that writes a decent stand-alone HTML file to a directory, with embedded styles and all. With all due respect, couldn't I just let people email or print the HTML file, as bokeh might have been suggesting? If this was your point, bokeh, sorry I'm so dense. Now I'm wondering why I actually need a file format other than HTML. I don't need to hide the HTML, and my scripts are tucked away on the server. The email recipients don't need special software - everyone has a browser. But one other thing is worrying me - is HTML a file type that people's email software will allow?
Copy linkTweet thisAlerts:
@felgallMar 26.2007 — The only coding that I have done usinng PHP to generate PDF files has not involved HTML at all as there is nothing really in common between the two formats. Instead you use the methods provided by the PDF class that you have chosen to apply the positioning and styling that you want to plain text. What PDF documents I have generated are entirely unconnected to any HTML pages since none of them are intended as copies of a web page as such but have been created as PDFs rather than in HTML because I need the functionality that PDFs provide that HTML does not. There are lots of things you can do when generating a PDF such as embedding specific fonts that can't be done at all with HTML.

Any HTML web page can be printed out but how it will look will depend on what fonts are installed on the computer that is printing it as well as the configuartion of the printer. You can't get an HTML page to print exactly the same for everyone the way you can for a PDF.

You can also create emails in HTML format (or even include both plain text and HTML versions in the one email). Many people do have email programs that support HTML format but not everyone does and some of those that do prefer to disable it. You can embed images in the email for the HTML to use or link to them from your site but most people have linking turned off as that is one way that spammers use to confirm email addresses. Most will also have Javascript turned off in their email program if it is supported at all. Provided that you take those things into account then HTML may be perfectly suited to what you need.
Copy linkTweet thisAlerts:
@bokehMar 26.2007 — But one other thing is worrying me - is HTML a file type that people's email software will allow?[/QUOTE]Yes it is but I would just send the html file as an attachment to the email; that way they will open it with a browser and not an email client (for maximum compatibility). Locate your CSS in the html file so it is a standalone and link to your images with full, absolute URIs.

If you need help attaching the file to the email I can help you with that.
Copy linkTweet thisAlerts:
@strBeanauthorMar 26.2007 — Thanks, bokeh and felgall (and Aussie and Andy) for a rich and stimulating discussion of an important question.

I appreciate the tips about HTMl emails, etc.; I was already up-to-speed on that. My confusion was mostly from the fact that I hardly ever see people sending static HTML files as a standard document type. I worried that this was because of a security risk. bokeh's point that if the HTML file is attached to the email, then it will be opened in a browser, which should be safe - is just the assurance I need.

I'm all set, guys. Many many thanks.
×

Success!

Help @strBean spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...