简体   繁体   English

如何将pdf(从db中获取php脚本)包含到HTML中

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

I want to include a pdf into html. 我想将pdf包含到html中。

I´ll get the PDF File from a DB. 我将从数据库获取PDF文件。

The PHP works fine and shows me the pdf in the Browser PDF-Reader. PHP可以正常工作,并在浏览器PDF阅读器中向我显示pdf。

    <?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.. 如果我想将其添加到简单的html中以对其进行客制化,它将无法正常工作。

Just want a little div around it or sth. 只是想在它周围某处或某处。 else 其他

Well you can create an iframe and display the pdf file inside the iframe. 那么您可以创建一个iframe,并在iframe中显示pdf文件。 You can customize the border of the iframe using CSS. 您可以使用CSS自定义iframe的边框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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