displaying a pdf coming out of a mysql-db in a frame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Kirchner

    #1

    displaying a pdf coming out of a mysql-db in a frame

    Hi!

    I have a mysql-database with some pdf in it.
    I can send them to a webbrowser using this script:

    <?php
    //output.php4
    $sql = "SELECT * FROM tbfiles WHERE tbfiles.ID={$id }";
    $result = mysql_query($sq l);
    $dateien = mysql_fetch_obj ect($result);
    $daten = $dateien->Inhalt;
    $name = $dateien->Dateiname;
    $groesse = $dateien->Groesse;
    $typ = $dateien->Typ;

    header("Content-type: $typ");
    header("Content-length: $groesse");
    header("Content-Disposition: attachment; filename=$name" );
    echo $daten;
    ?>

    My problem is that I get a download dialog where I want to save the pdf but
    I want to open it in a fram or iframe like this:
    <iframe src="./output.php4?id= 129" width="100%" height="400"
    name="outputbox ">
    where id=129 indicates my document.

    I get the correct result in Internet Explorer (but not in Opera) if I change
    the script like this:

    header("Content-type: image/jpeg");
    header("Content-Disposition: inline; filename=$name" );

    Does anybody know a solution for Opera? Then I could provide different
    scripts depending on the browser.
    Or even better a solution working in all browsers?

    Thank you very much.

    Best wishes

    Martin



  • Shawn Wilson

    #2
    Re: displaying a pdf coming out of a mysql-db in a frame

    Martin Kirchner wrote:[color=blue]
    >
    > I have a mysql-database with some pdf in it.
    > I can send them to a webbrowser using this script:
    >
    > <?php
    > //output.php4
    > $sql = "SELECT * FROM tbfiles WHERE tbfiles.ID={$id }";
    > $result = mysql_query($sq l);
    > $dateien = mysql_fetch_obj ect($result);
    > $daten = $dateien->Inhalt;
    > $name = $dateien->Dateiname;
    > $groesse = $dateien->Groesse;
    > $typ = $dateien->Typ;
    >
    > header("Content-type: $typ");
    > header("Content-length: $groesse");
    > header("Content-Disposition: attachment; filename=$name" );
    > echo $daten;
    > ?>
    >
    > My problem is that I get a download dialog where I want to save the pdf but
    > I want to open it in a fram or iframe like this:
    > <iframe src="./output.php4?id= 129" width="100%" height="400"
    > name="outputbox ">
    > where id=129 indicates my document.
    >
    > I get the correct result in Internet Explorer (but not in Opera) if I change
    > the script like this:
    >
    > header("Content-type: image/jpeg");
    > header("Content-Disposition: inline; filename=$name" );[/color]

    I'd give this a try:

    header("Content-type: $typ");
    header("Content-Disposition: inline; filename=$name" );

    No idea whether that'll fix your problem or not though...

    Shawn
    --
    Shawn Wilson
    shawn@glassgian t.com

    Comment

    • Martin Kirchner

      #3
      Re: displaying a pdf coming out of a mysql-db in a frame

      Thank you for your answer!
      But it doesn't work.
      So if anybody has another idea you're welcome!

      Best wishes

      Martin


      Comment

      • Doug H

        #4
        Re: displaying a pdf coming out of a mysql-db in a frame

        Martin Kirchner wrote:[color=blue]
        > Hi!
        >
        > I have a mysql-database with some pdf in it.
        > I can send them to a webbrowser using this script:
        >
        > <?php
        > //output.php4
        > $sql = "SELECT * FROM tbfiles WHERE tbfiles.ID={$id }";
        > $result = mysql_query($sq l);
        > $dateien = mysql_fetch_obj ect($result);
        > $daten = $dateien->Inhalt;
        > $name = $dateien->Dateiname;
        > $groesse = $dateien->Groesse;
        > $typ = $dateien->Typ;
        >
        > header("Content-type: $typ");
        > header("Content-length: $groesse");
        > header("Content-Disposition: attachment; filename=$name" );
        > echo $daten;
        > ?>
        >
        > My problem is that I get a download dialog where I want to save the pdf but
        > I want to open it in a fram or iframe like this:
        > <iframe src="./output.php4?id= 129" width="100%" height="400"
        > name="outputbox ">
        > where id=129 indicates my document.
        >
        > I get the correct result in Internet Explorer (but not in Opera) if I change
        > the script like this:
        >
        > header("Content-type: image/jpeg");
        > header("Content-Disposition: inline; filename=$name" );
        >
        > Does anybody know a solution for Opera? Then I could provide different
        > scripts depending on the browser.
        > Or even better a solution working in all browsers?
        >
        > Thank you very much.
        >
        > Best wishes
        >
        > Martin
        >
        >
        >[/color]

        Here's a link to a clever class file for generating PDF's ... perhaps it
        will help you find a solution.

        http://www.ros.co.nz/pdf

        Comment

        • Al C.

          #5
          Re: displaying a pdf coming out of a mysql-db in a frame

          Doug H wrote:
          [color=blue]
          > Martin Kirchner wrote:[color=green]
          >> Hi!
          >>
          >> I have a mysql-database with some pdf in it.
          >> I can send them to a webbrowser using this script:
          >>
          >> <?php
          >> //output.php4
          >> $sql = "SELECT * FROM tbfiles WHERE tbfiles.ID={$id }";
          >> $result = mysql_query($sq l);
          >> $dateien = mysql_fetch_obj ect($result);
          >> $daten = $dateien->Inhalt;
          >> $name = $dateien->Dateiname;
          >> $groesse = $dateien->Groesse;
          >> $typ = $dateien->Typ;
          >>
          >> header("Content-type: $typ");
          >> header("Content-length: $groesse");
          >> header("Content-Disposition: attachment; filename=$name" );
          >> echo $daten;
          >> ?>
          >>
          >> My problem is that I get a download dialog where I want to save the pdf but
          >> I want to open it in a fram or iframe like this:
          >> <iframe src="./output.php4?id= 129" width="100%" height="400"
          >> name="outputbox ">
          >> where id=129 indicates my document.
          >>
          >> I get the correct result in Internet Explorer (but not in Opera) if I
          >> change the script like this:
          >>
          >> header("Content-type: image/jpeg");
          >> header("Content-Disposition: inline; filename=$name" );
          >>
          >> Does anybody know a solution for Opera? Then I could provide different
          >> scripts depending on the browser.
          >> Or even better a solution working in all browsers?[/color][/color]

          Take a look at www.fpdf.org. We use this pdf creation class in our JAYA123 web
          application for small businesses (www.jaya123.com try the demo) . After we
          send all the pdf stuff to a file ($fileoutname), the following line seems to
          work well at redirection for all browsers.



          echo "<HTML><SCRIPT> document.locati on='$fileoutnam e';</SCRIPT></HTML>";

          Al C.
          _______________ _______________ _______________ _____________
          Adams-Blake Company, Inc.
          ***
          JAYA123 - the web-based total-office system for the
          small biz. Order entry, billing, bookkeeping, etc. for $14.95
          a month. Perfect for the small business or start-up.
          See demo at: http://www.jaya123.com
          ***


          Comment

          • Martin Kirchner

            #6
            Re: displaying a pdf coming out of a mysql-db in a frame

            > I have a mysql-database with some pdf in it.[color=blue]
            > I can send them to a webbrowser using this script:[/color]

            A short addition: the pdf-files as well as some as docs and pictures are
            stored as binaries in the database. Sorry for the misunderstandin gs.

            Bye Martin

            [color=blue]
            > I have a mysql-database with some pdf in it.
            > I can send them to a webbrowser using this script:
            >
            > <?php
            > //output.php4
            > $sql = "SELECT * FROM tbfiles WHERE tbfiles.ID={$id }";
            > $result = mysql_query($sq l);
            > $dateien = mysql_fetch_obj ect($result);
            > $daten = $dateien->Inhalt;
            > $name = $dateien->Dateiname;
            > $groesse = $dateien->Groesse;
            > $typ = $dateien->Typ;
            >
            > header("Content-type: $typ");
            > header("Content-length: $groesse");
            > header("Content-Disposition: attachment; filename=$name" );
            > echo $daten;
            > ?>
            >
            > My problem is that I get a download dialog where I want to save the pdf
            > but I want to open it in a fram or iframe like this:
            > <iframe src="./output.php4?id= 129" width="100%" height="400"
            > name="outputbox ">
            > where id=129 indicates my document.
            >
            > I get the correct result in Internet Explorer (but not in Opera) if I
            > change the script like this:
            >
            > header("Content-type: image/jpeg");
            > header("Content-Disposition: inline; filename=$name" );
            >
            > Does anybody know a solution for Opera? Then I could provide different
            > scripts depending on the browser.
            > Or even better a solution working in all browsers?
            >
            > Thank you very much.
            >
            > Best wishes
            >
            > Martin
            >
            >
            >[/color]


            Comment

            • Michael Fesser

              #7
              Re: displaying a pdf coming out of a mysql-db in a frame

              .oO(Martin Kirchner)
              [color=blue]
              >My problem is that I get a download dialog where I want to save the pdf but
              >I want to open it in a fram or iframe like this:
              >[...]
              >
              >Does anybody know a solution for Opera? Then I could provide different
              >scripts depending on the browser.[/color]

              Won't work.
              [color=blue]
              >Or even better a solution working in all browsers?[/color]

              There's no solution. Handling downloaded files is completely up to the
              client and depends on the user agent's configuration. Some will open a
              PDF "inline" if a plugin is available for that and enabled, others will
              prompt the download dialog.

              Micha

              Comment

              Working...