I use FPDI library for php and try to add text into pdf file. It's work but when i change the text to Hebrew i got
×•× ̈×– הצלח×a×TM להוס×TM×£ × ̃×§×¡× ̃
This is my code:
<?php
use setasign\Fpdi\Fpdi;
use \setasign\Fpdi\PdfParser\StreamReader;
require_once('fpdf/fpdf.php');
require_once('fpdi/src/autoload.php');
$rawPostBody = file_get_contents('php://input');
$signatures = (array)json_decode($rawPostBody);
$fileURL = $signatures['filURL'];
$signaturesData = $signatures['signatures'];
// Initial Fpdi
$pdf = new Fpdi();
// Load external pdf file with StreamReader (We Use StreamReader Only for External file)
$fileContent = file_get_contents($fileURL,'rb');
$pdf->setSourceFile(StreamReader::createByString($fileContent));
// Get number of pages.
$pageCount = $pdf->setSourceFile(StreamReader::createByString($fileContent));
// Illiterate and create pdf pages.
for ($pageNumber = 1; $pageNumber <= $pageCount; $pageNumber++) {
$tplId = $pdf->importPage($pageNumber);
$s = $pdf->getTemplatesize($tplId);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',10);
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L', array($s['w'], $s['h'])); // This gets it the right dimensions
$pdf->useTemplate($tplId, null, null, null, null, true);
foreach ($signaturesData as $signa) {
if($signa->page == $pageNumber) {
$pdf->SetXY(number_format($signa->positionX), number_format($signa->positionY * 0.264583));
$pdf->Write(0, "שלום שלום");
}
}
}
$pdf->Output('pdf-with-value.pdf', 'D');
I read some post with a similar problem but I couldn't figure out what exactly I needed to do. Thanks