PDF don't open on screen

Discussion in 'Web Design and Development' started by nomade, Jan 30, 2008.

  1. nomade macrumors member


    Dec 2, 2006
    I wrote a PHP script that open a new window (javascript window.open) that call a PDF file. On some browser PDF appear correctly but on some other not.

    What 's more surprising is that when I test this script on Safari on my Macbook pro everything work fine but on my other computer with the same version of Safari I have a blank screen.

    Here's the address of that page : http://feteduchocolat.ca/fr/info.php

    Any suggestion will be welcomed.:confused::confused:
  2. SrWebDeveloper macrumors 68000


    Dec 7, 2007
    Alexandria, VA, USA
    For some excellent free open source classes to convert HTML or SQL results to PDF format, visit phpclasses.org and search for PDF. Some classes work better than others, and the better ones do all the processing server side, generate the correct http headers and automatically prompt the user to either "open or save as" based on their computer/browser plugin or MIME setup.

    That's why it's easier if you put all this in one standalone PHP script - when it runs directly via browser, the http headers is the only output sent so the user is prompted to open/save as and your other window is left intact.

    Try not to rely on JavaScript or JS functions for the window open or this type of thing. Simply write the script, include the class and any other files in your native code base, and set the target to "_blank" in the links users click on to generate a PDF.

    <a href="createPDF.php?section=1" target="_blank">Download PDF for Section 1</a>

    That calls your PHP script which does whatever it does now, in a new browser window, no reliance on JS and cross browser compatible after you find the class the works for you.

  3. nomade thread starter macrumors member


    Dec 2, 2006
    re: PDF don't open on screen

    Thanks. I did get rid of the javascript action and that resolve my problem.

    I already use a PHP class to generate the PDF and It work fine.:D

Share This Page