Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在DOMPDF中生成带有阿拉伯文本的PDF,并给出问号_Php_Pdf_Dompdf_Utf8 Decode - Fatal编程技术网

Php 在DOMPDF中生成带有阿拉伯文本的PDF,并给出问号

Php 在DOMPDF中生成带有阿拉伯文本的PDF,并给出问号,php,pdf,dompdf,utf8-decode,Php,Pdf,Dompdf,Utf8 Decode,我有一个网页包含的形式是自动完成与阿拉伯文和英文文本 当我用DOMPDF生成时,英文文本看起来不错,但阿拉伯文显示为问号。。。我将UTF-8设置为字符集,但不工作,甚至尝试 iconv('UTF-8','WINDOWS-1250',$pdf_html); 但是没有起作用 下面是html的代码 <?php require("login3.php"); ?> <?php if (!empty($_POST)) { // Used for later to determin

我有一个网页包含的形式是自动完成与阿拉伯文和英文文本 当我用DOMPDF生成时,英文文本看起来不错,但阿拉伯文显示为问号。。。我将UTF-8设置为字符集,但不工作,甚至尝试

iconv('UTF-8','WINDOWS-1250',$pdf_html);
但是没有起作用

下面是html的代码

<?php require("login3.php"); ?>
<?php 
 if (!empty($_POST)) {


// Used for later to determine result
$success = $error = false;

// Object syntax looks better and is easier to use than arrays to me
$post = new stdClass;

    // Usually there would be much more validation and filtering, but this
// will work for now.
foreach ($_POST as $key => $val)
    $post->$key = trim(strip_tags($_POST[$key]));


// Check for blank fields
if (empty($post->itemCode) OR empty($post->itemDesc) OR empty($post->itemQty) OR    empty($post->itemPrice) OR empty($post->itemAgent))
    $error = true;

else {

    // Get this directory, to include other files from
    $dir = dirname(__FILE__);

    // Get the contents of the pdf into a variable for later
    ob_start();
    require_once($dir.'/pdf.php');
    $pdf_html = ob_get_contents();
    ob_end_clean();

    // Load the dompdf files
    require_once($dir.'/dompdf/dompdf_config.inc.php');

    $dompdf = new DOMPDF(); $pdf_html = iconv('UTF-8','WINDOWS-1250',$pdf_html);// Create   new instance of dompdf
    $dompdf->load_html($pdf_html); // Load the html
    $dompdf->render(); // Parse the html, convert to PDF
    $pdf_content = $dompdf->output(); // Put contents of pdf into variable for  later

    // Get the contents of the HTML email into a variable for later
    ob_start();
    require_once($dir.'/html.php');
    $html_message = ob_get_contents();
    ob_end_clean();

            date_default_timezone_set('Asia/Manila');
            $tym = date('m-d-Y : hi a');
            $filename = ' Order '.$tym;
            $dompdf->load_html($_SESSION['prints']['table']);

            $dompdf->stream( $_SESSION["username"] . $filename. ".pdf");      // Streams   the PDF to the client. Will open a download dialog by default

    // Load the SwiftMailer files
    require_once($dir.'/swift/swift_required.php');

    $mailer = new Swift_Mailer(new Swift_MailTransport()); // Create new i nstance of SwiftMailer

    $message = Swift_Message::newInstance()
                       ->setSubject('New Order') // Message subject
                   ->setTo(array('example@aol.com',  'example@aol.com' => 'Orange Pharmacy Store')) // Array of people to send to
                   ->setFrom(array('example@net.tutsplus.com' => 'order')) // From:
                   ->setBody($html_message, 'text/html') // Attach  that HTML message from earlier
                   -  >attach(Swift_Attachment::newInstance($pdf_content, 'Order.pdf', '')); // Attach the generated PDF from earlier

            // Send the email, and show user message
    if ($mailer->send($message))
        $success = true;
    else 
            $error = true;

   }

     }
   ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

     <html xmlns="http://www.w3.org/1999/xhtml" lang="ar" xml:lang="ar">
      <head>
      <title> Order System</title>
  <style type="text/css" title="currentStyle">
            @import "css/layout-styles.css";
            @import "css/themes/smoothness/jquery-ui-1.8.4.custom.css";
   </style>

   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<!-- jQuery libs -->
<script  type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<script  type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
<script type="text/javascript" src="js/atooltip.jquery.js"></script>
<script type="text/javascript" src="js/kwicks-1.5.1.pack.js"></script>
<script type="text/javascript" src="js/script.js"></script>

<!-- My jQuery Script to make everything work -->
<script  type="text/javascript" src="js/jq-ac-script.js"></script>

       </head>
     <body background="images/bg.jpg";>
     <div id="cont">
     <div style="position:absolute; top: 10px; left: 25px;">
     <a href="index.php" class="normaltip" style="text-decoration:none" title="Home"> <img src="images/home.png"height="48" width="48"></a></div>
      <div style="position:absolute; top: 60px; left: 25px;">
       <a href="order.php" class="normaltip" style="text-decoration:none" title="New Order"><img src="images/system-software-update.png"height="48" width="48"></a></div>

        <div id="container">
      <h1 align="center"><img src="images/418694_259331167468533_385322251_n.jpg"></h1>
       <div class="panel">
          <div class="title-large">
            <div class="theme"></div>

    <p>
        <h4 align="left"><b>        Branch : <FONT COLOR="white"><?php   echo($_SESSION["username"]); ?></b></h4>
       <script type="text/javascript">
      function GetClock(){
      d = new Date();
      nday   = d.getDay();
      nmonth = d.getMonth();
      ndate  = d.getDate();
      nyear = d.getYear();
      nhour  = d.getHours();
      nmin   = d.getMinutes();
      nsec   = d.getSeconds();

      if(nyear<1000) nyear=nyear+1900;

      if(nhour ==  0) {ap = " AM";nhour = 12;} 
       else if(nhour <= 11) {ap = " AM";} 
       else if(nhour == 12) {ap = " PM";} 
       else if(nhour >= 13) {ap = " PM";nhour -= 12;}

        if(nmin <= 9) {nmin = "0" +nmin;}
        if(nsec <= 9) {nsec = "0" +nsec;}


           document.getElementById('clockbox').innerHTML=""+ (nmonth+1)+"/"+ndate+"/"+nyear+"  "+nhour+":"+nmin+":"+nsec+ap+"";
           setTimeout("GetClock()", 1000);
        }
          window.onload=GetClock;
        </script>
      <div id="clockbox"></div></font></div>
       <?php if ($success) { ?>
        <div class="message success">
            <h4>Order Successfully Sent to Store </h4>
        </div>
    <?php } elseif ($error) { ?>
        <div class="message error">
            <h4>Sorry, an error occurred. Try again!</h4>
        </div>
    <?php } ?>
            <div class="content inpad">

                 <div id="messageBox" style="margin-left:15px; padding-left:20px;  padding-bottom:5px; border:1px #ccc solid; display:none;"></div>

                        <form method="post" action="#" id="itemsForm">

                        <h1 align="center"><font color="black"><b>Branch Order Form</b>  </font></h1><br><br>
           <select name="Priority" size="1">
          <option value="Daily">Daily</option>
           <option value="Monthly">Monthly</option>
           <option value="Urgent">Urgent</option>
              </select>
                            <table id="itemsTable" class="general-table">
                                <thead>
                                <tr>
                                    <th></th>
                                    <th>Item Code</th>
                                    <th>Item Description</th>
                                    <th>Item Qty</th>
                                    <th>Item Price</th>
                                    <th>Item Agent</th>
                                </tr>
                                </thead>
                                <tbody>
                                    <tr class="item-row">
                                        <td></td>
                                        <td><input name="itemCode[]" value="" class="tInput" id="itemCode" readonly="readonly" /> </td>
                                        <td><input name="itemDesc[]" value="" class="tInput" id="itemDesc"  tabindex="1"/></td>
                                        <td><input name="itemQty[]" value="" class="tInput" id="itemQty" tabindex="2"/></td>
                                        <td><input name="itemPrice[]" value="" class="tInput" id="itemPrice" readonly="readonly" /> </td>
                                        <td><input name="itemAgent[]" value="" class="tInput" id="itemAgent" readonly="readonly" /></td>
                                    </tr>
                                </tbody>
                            </table>
                        <a href="#" id="addRow" class="button-clean large"><span> <img  src="images/icon-plus.png" alt="Add" title="Add Row" /> Add Item</span></a>&nbsp;&nbsp;&nbsp;

                    </div>
                  <input type="submit" value="SEND TO THE STORE">
                </form>

            </div>
    </div>

   </body>
   </html>

订单系统
@导入“css/layout styles.css”;
@导入“css/themes/smoothness/jquery-ui-1.8.4.custom.css”;

分支机构:
函数GetClock(){
d=新日期();
nday=d.getDay();
nmonth=d.getMonth();
ndate=d.getDate();
nyear=d.getYear();
nhour=d.getHours();
nmin=d.getMinutes();
nsec=d.getSeconds();
如果(nyear
很抱歉,发生错误。请重试!
分支机构订单表

每日的 月刊 紧急的 项目代码 项目说明 项目数量 项目价格 商品代理
以及pdf.php代码:

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <html>
       <style type="text/css" title="currentStyle">
            @import "css/layout-styles.css";
            @import "css/themes/smoothness/jquery-ui-1.8.4.custom.css";
       </style>
      <head> 
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <br>
        <br>
         <br>
           <h1 align="center"><img  src=/418694_259331167468533_385322251_n.jpg></h1>
           <br>
         </head> 
         <body>
          <br>
   <h3 align="center"><b>Items&nbsp;<?php echo($_POST["Priority"]); ?>&nbsp;Order <br>  Branch : <FONT COLOR="ORANGE"><?php echo($_SESSION["username"]); ?></h3>
    <br>
     <hr>
     <h6>
 <table id="itemsTable" border="1" width="100%">
                                <thead>
                                <tr>
                                    <th></th>
                                    <th>Item Code</th>
                                    <th>Item Description</th>
                                    <th> Qty</th>
                                    <th> Price</th>
                                    <th> Agent</th>
                                </tr>
                                </thead>
                                <tbody>
            <?php foreach  ($_POST['itemCode'] as $Key=> $itemCode) {  
        $itemDesc=$_POST["itemDesc"][$Key];
        $itemPrice=$_POST["itemPrice"][$Key];
        $itemQty=$_POST["itemQty"][$Key];
        $itemAgent=$_POST["itemAgent"][$Key];   
           echo "<tr><td></td><td>" . $itemCode . "</td><td>" . $itemDesc . "</td><td>" . $itemQty . "</td><td>" . $itemPrice . "</td><td>" . $itemAgent ."</td></tr>";
          }
        ?>

                                </tbody>
                            </table>
         </h6>
         <script type="text/php">

   if ( isset($pdf) )

      {


    $font = Font_Metrics::get_font("verdana");

    // If verdana isn't available, we'll use sans-serif.

    if (!isset($font)) { Font_Metrics::get_font("sans-serif"); }

    $size = 6;

    $color = array(0,0,0);

    $text_height = Font_Metrics::get_font_height($font, $size);


    $w = $pdf->get_width();

    $h = $pdf->get_height();


    // ------------------ FOOTER ------------------------------------------



    if ($PAGE_NUM > 0)

    {

        $footer = $pdf->open_object();

        $y = $h - 3 * $text_height - 24;


        $text = "Orange Pharmacy    Tel:5536170 - Fax :5536171"; //"Page {PAGE_NUM} of  {PAGE_COUNT}";


        $width = Font_Metrics::get_text_width("Orange Pharmacy    Tel:5536170 - Fax :5536171", $font, $size);

        $pdf->page_text($w / 2 - $width / 2, $y, $text, $font, $size, $color);


        // Copyright line

        $y += $text_height * 2;


        $text = "my company footer";


        // Center the text

        $width = Font_Metrics::get_text_width($text, $font, $size);

        $pdf->page_text($w / 2 - $width / 2, $y, $text, $font, $size, $color);


        // Add a logo

        $img_w = 0.5 * 72; // 0,5 inches, in points

        $img_h = 0.5 * 72; // 0,5 inch, in points -- change these as required

        //$pdf->image("/images/300px- Orange_plus.svg.png", "png", 0, $y, $img_w, $img_h);


        $pdf->close_object();

        $pdf->add_object($footer, "all");

    }


    // ------------------ FOOTER END ------------------------------------------



          }

       </script>
         <script type="text/php">
        if ( isset($pdf) ) {
        $font = Font_Metrics::get_font("helvetica", "bold");
         $pdf->page_text(36, 9, "Page: {PAGE_NUM} of {PAGE_COUNT}",
                    $font, 6, array(0,0,0));
         }
      </script> 
          </body>   
              </html>

@导入“css/layout styles.css”;
@导入“css/themes/smoothness/jquery-ui-1.8.4.custom.css”;





项目订单
分支机构:

项目代码 项目说明 数量 价格 代理人 如果(isset($pdf)) { $font=font_度量:获取字体(“verdana”); //如果verdana不可用,我们将使用无衬线。 如果(!isset($font)){font_Metrics::get_font(“sans serif”);} $size=6; $color=数组(0,0,0); $text\u height=Font\u Metrics::get\u Font\u height($Font,$size); $w=$pdf->get_width(); $h=$pdf->获取高度(); //---------页脚------------------------------------------ 如果($PAGE_NUM>0) { $footer=$pdf->open_object(); $y=$h-3*$text\U height-24; $text=“橙色药房电话:5536170-传真:5536171”/“第{Page_NUM}页,共{Page_COUNT}”; $width=Font_Metrics::get_text_width(“橙色药房电话:5536170-传真:5536171”,$Font,$size); $pdf->page_text($w/2-$width/2,$y,$text,$font,$size,$color); //版权线 $y+=$text\U height*2; $text=“我的公司页脚”; //将文本居中 $width=Font\u度量::获取文本宽度($text,$Font,$size); $pdf->page_text($w/2-$width/2,$y,$text,$font,$size,$color); //添加一个标志 $img_w=0.5*72;//0.5英寸,以点为单位 $img_h=0.5*72;//0,5英寸,以点为单位--根据需要更改这些值 //$pdf->image(“/images/300px-Orange\u plus.svg.png”,“png”,0,$y,$img\u w,$img\u h); $pdf->close_object(); $pdf->add_对象($footer,“all”); } //---------页脚结束------------------------------------------ } 如果(isset($pdf)){ $font=font_度量:获取字体(“helvetica”、“bold”); $pdf->page_text(36,9,“page:{page_NUM}共{page_COUNT}”, $font,6,数组(0,0,0)); }

你能帮我吗?Thanx.

通常你需要在你的服务器上安装字体-至少我习惯用WKHTMLTOPDFH做这件事。你是否遵循了中的说明?此外,你可以通过使用固定位置元素创建页眉/页脚来简化事情(尽管目前无法使用此方法进行页面计数).我使用了名为A_Nefel_Adeti的字体,我安装了用于普通、粗体、斜体和粗体斜体的.ttf和.ufm文件..并将样式添加到html和pdf页面,但仍然得到问号!!我找不到我的错误所在..任何想法!感谢@BrianS提供关于页脚和页眉的说明,我将其更新为固定位置元素..检查此[链接]