简体   繁体   中英

How to include pdf (getting with php script from db) into HTML

I want to include a pdf into html.

I´ll get the PDF File from a DB.

The PHP works fine and shows me the pdf in the Browser PDF-Reader.

    <?php

    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

    //MySQL Verbindung hier einfügen
    $mysqli = new mysqli("ip", "root", "password", "name");
    if ($mysqli->connect_errno) {
        die("Connection refused: " . $mysqli->connect_error);
    }

    try{
       $sql = "SELECT file FROM Master_Ordner_AMS WHERE id = 1";
       $result = mysqli_query($mysqli, $sql);        
       $row = mysqli_fetch_object($result);
       header('Content-type: application/pdf');

      $pdf = $row->file;   

    }catch(Exception $e){
        echo "caught exception: ", $e->getMessage(), "\n";
    }

?>

If i want to add it in a simple html to custumize it, it doesnt work..

Just want a little div around it or sth. else

Well you can create an iframe and display the pdf file inside the iframe. You can customize the border of the iframe using CSS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM