Cropping a PDF using Ghostscript 9.01

First, take note that the measurement unit for PDF is the same as for PostScript: it’s called a point [pt]. 72 points == 1 inch == 25.4 millimeters Assuming you have a page size of A4. Then the media dimensions are: 595 points width == 210 millimeters 842 points height == 297 millimeters Assuming you … Read more

Detecting browser print event

You can now detect a print request in IE 5+, Firefox 6+, Chrome 9+, and Safari 5+ using the following technique: (function() { var beforePrint = function() { console.log(‘Functionality to run before printing.’); }; var afterPrint = function() { console.log(‘Functionality to run after printing’); }; if (window.matchMedia) { var mediaQueryList = window.matchMedia(‘print’); mediaQueryList.addListener(function(mql) { if … Read more

Proper MIME media type for PDF files

The standard Media Type (formerly known as MIME types) is application/pdf. The assignment is defined in RFC 3778, The application/pdf Media Type, referenced from the Media Types registry. Media Types are controlled by a standards body, The Internet Assigned Numbers Authority (IANA). This is the same organization that manages the root name servers and the … Read more

How do I force files to open in the browser instead of downloading (PDF)?

To indicate to the browser that the file should be viewed in the browser, the HTTP response should include these headers: Content-Type: application/pdf Content-Disposition: inline; filename=”filename.pdf” To have the file downloaded rather than viewed: Content-Type: application/pdf Content-Disposition: attachment; filename=”filename.pdf” The quotes around the filename are required if the filename contains special characters such as filename[1].pdf … Read more