我有一个包含自动填写阿拉伯语和英语文本的表单的页面 当我使用DOMPDF生成它时,英文文本看起来很好,但阿拉伯语显示为问号...我将UTF-8设置为charset但不工作甚至尝试
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>
</div>
<input type="submit" value="SEND TO THE STORE">
</form>
</div>
</div>
</body>
</html>
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 <?php echo($_POST["Priority"]); ?> 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>
你能帮帮我吗?感谢名单。