Anything special with a PDF?

  powerless 20:13 02 Feb 05

So what's the deal with offering PDF's on the web?

Anything special I should know about?

  Pesala 20:43 02 Feb 05

PDFs are convenient since they retain the layout of the orginal document, but not if the user doesn't have the right fonts and you don't embed them.

File sizes can be big, so like with graphics, optimizing PDFs for the web is important. I found the smallest PDF sizes can be achieved by using graphics at the size and quality you need before making the PDF. Use less fonts, or only standard fonts, then you don't need to embed them.

Layout and design need to be different if the PDFs are intended for printing (e.g. as booklets) than if they are intended for screen reading.

Some degree of copy protection can be built-in to PDFs, but as usual it is easy to get around it if people really want to.

Larger PDFs can be compressed a little with a good archive program, but it is usually more convenient to leave them uncompressed, then people can view them in their browser. PDFs are already reasonably well compressed. I always put the file size of PDFs by the link to warn dial-up users.

A good program to produce them is Serif Page Plus. A free PDF printer driver like Primo PDF is useful for producing them from any Windows application.

  Sir Radfordin 22:57 02 Feb 05

Nothing to add to the above really. PDFs common use seems to be to put online things that are produced for an off-line format (eg newsletters, forms etc).

Have been playing around with Macromdedias "FlashPaper" and am impressed with how good it seems to be.

  Taran 17:35 03 Feb 05

You might want to force the file to download, rather than allow it to open into the browser using the Acrobat plugin, which is how a standard link would work.

There are any number of ways of doing this. If you want some sample code to demonstrate the process let me know. Sometimes I find it is desirable to have the file download by default to the users machine, rather than allow it to open into the browser.

  powerless 00:47 05 Feb 05


As I hate when that happens.


Another thing; I point Adobe to a HTML file for it to create a PDF. It does not do it as good as I expected [Probably me not fully understanding my new toy].

So I copy the contents of the file into Word [doc] and tell Adobe to create a PDF from the doc file and it does it with ease.

The images are thumbnailed and contain a hyperlink to the hard drive so I chnage the link to the webspace.

Now this would require an internet connection for the user to see the large image.

For printing it wouldn't be very good as the thumbnails are too small. But inserting larger images would not be wise?

  Forum Editor 08:55 05 Feb 05

If you simply remove the .pdf file extension from the file on the server you should find that the browser is forced to produce the "run from this location or save" dialogue when the user clicks your link. All the user then has to do is choose - if he/she chooses to save the file the browser will recognise the pdf file for what it is and automatically add the .pdf extension back again.

When you want to create a PDF file just use the File/print command in your application menu. Select Acrobat Distiller as the printer and the PDF will be created and saved to the location you select.

  Taran 14:50 05 Feb 05

Assuming you are on an Apache web server with PHP support, copy this into a Notepad text file, save it as download.php or save it as download.txt then rename it to download.php



$filename = $_GET['file'];

$file_extension = strtolower(substr(strrchr($filename,"."),1));

if( $filename == "" )
echo "<html><title>Page Title</title><body>ERROR: download file NOT SPECIFIED. USE force-download.php?file=filepath</body></html>";
} elseif ( ! file_exists( $filename ) )
echo "<html><title>Page Title Goes In Here</title><body>ERROR: File not found. USE force-download.php?file=filepath</body></html>";
switch( $file_extension )
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/"; break;
case "ppt": $ctype="application/"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=".basename($filename).";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));



You can add or remove the necessary file extensions in the above code block that you want to force to download rather than load up into the web browser.

To use the file, drop it into the same directory as your PDF and make a line like this (remove the spaces between the URL elements):

http : // www . your_domain . com/ directory_name / download.php?file=File_Name.pdf

You can do a similar trick with the other dynamic web languages, and I rather like being able to force a file to download sometimes. It can fit in with certain requirements, but obviously does not need to be used all of the time.

It also saves user intervention where the file extension has to be manually added.

You can recode the script to hide your download directory location and expand it by building additional modules for download counting or username/password access restriction, but on its own it performs a nice function without doing your head in.

If you want or need an ASP or ASP.NET version give me a shout. Don't ask for JSP. I can do it, but I prefer not to since I hate JSP. Let's not get into that one...


  Taran 14:52 05 Feb 05

I forgot about the mangling of code snippets in the forum.

It should still work fine, but if you need to, feel free to request another example and I'll put it on a site for you to download.

  powerless 22:24 06 Feb 05

' Assuming you are on an Apache web server with PHP support '

errrrm I don't think so.

Which makes me think I could also not track the number of files downloaded?

Printing the PDF to PDF does not work as well as I thought it would.

So with a bit playing around in word i came up with this: click here

Does it meet approval?

  Taran 08:58 07 Feb 05

I made the assumption of an Apache web server since most people use them.

The guide looks very good; I've yet to read every word of it. In layout terms though it is easy on the eye.

Your web stats will tell you how many files have been downloaded.

I just sometimes like the ability to control user downloads a bit more than by putting a file online and offering a link to it.

Out of curiosity, what does your web host provide you with ?

  PurplePenny 19:34 07 Feb 05

I just put in a wrong URL so that it would throw up a 404 and the resultant error message is IIS.

But I've copied the code for my own use :-)

This thread is now locked and can not be replied to.

Surface Pro (2017) vs Surface Pro 4

20 groundbreaking 3D animation techniques

How to mine Bitcoin on Mac