【问题标题】:Fatal error: require_once(): Failed opening required 'dompdf/dompdf_config.inc.php' on line 15致命错误:require_once():无法在第 15 行打开所需的“dompdf/dompdf_config.inc.php”
【发布时间】:2020-12-31 08:44:35
【问题描述】:

我试图在突出显示正方形后生成网页的 PDF。 PDF 应包含网页上带有突出显示的方块的图像。

当我运行这段代码时,我得到了这个错误:

Fatal error: require_once(): Failed opening required 'dompdf/dompdf_config.inc.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\trial\trial.php on line 15

问题是什么,我该如何解决?

这里是trial.php

<?php
if(isset($_POST['send']))
{

$output ='
 <section>
    <div >
       <script>
            document.getElementById("mainImage");
       </script> 
    </div
 </section>
 ' ;

 require_once("dompdf/dompdf_config.inc.php");     
 $cart_body='<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>Squares</title></head><body><p>Test Printing...</p></body></html>';
         $dompdf = new Dompdf();
         $dompdf->load_html($output);//body -> html content which needs to be converted as pdf..
         $dompdf->render();
         $dompdf->stream("sample.pdf"); //To popup pdf as download
      }

    ?>


    <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <meta name="description" content="" />
    <meta name="author" content="" />
    <!-- Font Awesome icons (free version)-->
    <script src="https://use.fontawesome.com/releases/v5.15.1/js/all.js" crossorigin="anonymous"> 
    </script>
    <!-- Google fonts-->
    <link href="https://fonts.googleapis.com/css?family=Merriweather+Sans:400,700" rel="stylesheet" 
  />
    <link href="https://fonts.googleapis.com/css? 
    family=Merriweather:400,300,300italic,400italic,700,700italic" rel="stylesheet" type="text/css" 
   />
    <!-- Third party plugin CSS-->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific- 
 popup.min.css" rel="stylesheet" />
    <!-- Core theme CSS (includes Bootstrap)-->
    <link href="style.css" rel="stylesheet" />
</head>
<body id="page-top">

   
    <section class="page-section list-right">    

    <svg id="mainImage" width="564" height="409" onclick="handleSVGClick(event)">
        <image
            href="https://media.geeksforgeeks.org/wp-content/uploads/unique-rectangles-formed-using- 
         n-unit-squares.png"
            width="564"
            height="409"
        />
        <polygon title="1" points="21,385 24,309 100,309 101,385" />
        <polygon title="2" points="102,305 23,304 23,228 101,227" />
        <polygon title="3" points="103,225 26,228 25,149 99,151" />
        <polygon title="4" points="103,147 102,65 25,70 23,147" />
    </svg>
    <form  method="POST" >                  
        <input type="submit" class="btn btn-primary" value ="generate" name="send"/>
    </form>
    
    </section>


    
    <!-- Bootstrap core JS-->
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js"> 
    </script>
    <!-- Third party plugin JS-->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"> 
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific- 
     popup.min.js"></script>
    <!-- Core theme JS-->

    <script src="script.js"></script>
    <script type="text/javascript" src="mapper.js"></script>
    <script src="https://smtpjs.com/v3/smtp.js"> </script> 
    
</body>
这是`script.js`:
function handleSVGClick(event) {
  if (event.target.tagName === "polygon") {
    event.target.style.fill = `hsl(${Math.random() * 360}, 90%, 60%)`;
  }
}

还有style.css

polygon {
  stroke-width: 2px;
  stroke: #333;
  fill: transparent;
}

【问题讨论】:

    标签: php html pdf


    【解决方案1】:
    $svg = '<svg id="mainImage" width="564" height="409" onclick="handleSVGClick(event)">
            <image
                href="https://media.geeksforgeeks.org/wp-content/uploads/unique-rectangles-formed-using- 
             n-unit-squares.png"
                width="564"
                height="409"
            />
            <polygon title="1" points="21,385 24,309 100,309 101,385" />
            <polygon title="2" points="102,305 23,304 23,228 101,227" />
            <polygon title="3" points="103,225 26,228 25,149 99,151" />
            <polygon title="4" points="103,147 102,65 25,70 23,147" />
        </svg>';
    $output .= '<img src="data:image/svg+xml;base64,'.base64_encode($svg).'"  width="100" height="100" />';
    

    【讨论】:

    猜你喜欢
    • 2019-08-10
    • 1970-01-01
    • 2015-04-10
    • 2016-02-07
    • 1970-01-01
    • 2014-10-21
    • 2016-07-06
    相关资源
    最近更新 更多