I wanna create an Arabic pdf as same as the file witch I had in ms Execl format. While creating the pdf using tcpdf in php the Arabic charactors are displyaed as '????' marks.
The characters are copied from my excel file
$htmlcontent2 = '<span color="#0000ff">"مجوهرات السليمان"This is Arabic "مجوهرات السليمان" Example With TCPDF.</span>';
$pdf->WriteHTML($htmlcontent2, true, 0, true, 0);
the output file display as below,
??? ???? ?????? ??????This is Arabic "??????? ????????"
Example With TCPDF.
I solved this issue by adding the following line:
$pdf->SetFont('aealarabiya', '', 18);
It turned out that you need to set the proper font type to remove those ugly ????? characters.
The exmaple mentioned in this link was very useful to solve this issue.
I solved this issue by following this step:
Download TCPDF from here: http://sourceforge.net/projects/tcpdf/
Open the TCPDF file after download and go to FONTS
Copy these files
aealarabiya.ctg.z
aealarabiya.z
aealarabiya.php
Paste in this location: your WHCMS root / includes/fonts if fonts folder doesn't exist create it.
Go to WHCMS Admin Panel
Got to WHMCS Set Up / General Setting / Invoice / TCPDF Font Family / custom (aealarabiya)
there might be issue with your character set in your code
here is very good example for official TCPDF to use arabic character to write new pdf.
just go throw this example with your application you can sure solve your issue.
hope this will help to you.
Related
I'm trying now to convert a PDF file to JPG, using ImageMagick with PHP and CakePHP. The PDF is in perfect shape and it's right the way it should be, but the image generated from the PDF is always overflowing the borders of the file.
Until now, I've tried tweaking the code for the generation with no sucess, reading a lot from the PHP docs (http://php.net/manual/pt_BR/book.imagick.php).
Here are the convertion code:
$image = new Imagick();
$image->setResolution(300,300);
$image->setBackgroundColor('white');
$image->readImage($workfile);
$image->setGravity(Imagick::GRAVITY_CENTER);
$image->setOption('pdf:fit-to-page',true);
$image->setImageFormat('jpeg');
$image->setImageCompression(imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(60);
$image->scaleImage(1200,1200, true);
$image->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
$image->setImageAlphaChannel(Imagick::ALPHACHANNEL_REMOVE);
$image->writeImage(WWW_ROOT . 'files' . DS . 'Snapshots' . DS . $filename);
Here are the results:
https://imgur.com/a/ISBmDMv
The first image is the PDF before the conversion and the second one, the image generated from the PDF where the right side text overflows.
So, why this is happening? And if someone got some alternative for any tech used (the GhostScript, ImageMagick, etc) is also welcome!
Thanks everyone!
Its very hard to say why you see the result you do, without seeing the original PDF file, rather than a picture of it.
The most likely explanation is that your original PDF file uses a font, but does not embed that font in the PDF. When Ghostscript comes to render it to an image it must then substitute 'something' in place of the missing font. If the metrics (eg spacing) of the substituted font do not match precisely the metrics of the missing font, then the rendered text will be misplaced/incorrectly sized. Of course since its not using the same font it also won't match the shapes of the characters either.
This can result in several different kinds of problems, but what you show is pretty typical of one such class of problem. Although you haven't mentioned it, I can also see several places in the document where text overwrites as well, which is another symptom of exactly the same problem.
If this is the case then the Ghostscript back channel transcript will have told you that it was unable to find a font and is substituting a named font for the missing one. I can't tell you if Imagemagick stores that anywhere, my guess would be it doesn't. However you can copy the command line from the ImagMagick profile.xml file and then use that to run Ghostscript yourself, and then you will be able to see if that's what is happening.
If this is what is happening then you must either;
Create your PDF file with the fonts embedded (this is good practice anyway)
Supply Ghostscript with a copy of the missing font as a substitute
Live with the text as it is
So I'm trying to upload an exported Outlook email into my WordPress website through a plugin. Here's the start of the file in question:
http://prntscr.com/jxil42
When I echo the file this is the result I get.
http://prntscr.com/jximu4
Firstly I don't get where the "?" icons come from, then, when I move the uploaded file and open it, this is the result:
http://prntscr.com/jxinh9
I've no idea what's causing this, any help..?
Below one will help you to upload the unicode file.
$filename = iconv("utf-8", "cp936", $filename);
Reference
it may cause of encoding hash, encoding version type as i think
I am trying to set a name for a pdf file I generated with FPDF. However for some reason the browser changes some characters.
I am sending this:
$pdfTitle = 'Overview: 2017/2018'
$pdf->Output( 'D', $pdfTitle, true );
Yet when I save my pdf it changes some characters and I and the download name becomes: 'Overview_ 2017_2018'.
I am using UTF-8 encoding on my php file.
FPDF-documentation: http://fpdf.org/en/doc/output.htm
I have two questions:
How can I make sure the download name is the same as the one I set in my php file?
What is the underlying issue that changes the name?
PS: In the real project the string will come from a database, so I can only access the string programatically and not make direct changes to it.
You are using the special characters : and / in your filename in your code. Because of this fpdf is filtering your outputs filename.
For example:
Overview: 2017/2018
^ ^ are not supported as filename in Windows & some other OS.
Tip:
You may add .pdf in your name if file is not saving as pdf file.
We have an Image processing microservice that created rich images with text on top of it and we are in the process of adding arabic locale to our website
While translating some of the content to Arabic our translator told us that the text in generated images not rendering correctly in arabic - they appear with no ligatures, so every character is separated.
We currently use ImageMagick (6.8.9-9) with PHP and the text generation used ImagickDraw->annotateImage that worked fine until we hit that ligatures problem.
I googled a little and found "pango" that solves that problem and also allows some sort of "html" syntax to define multiple settings for one text line which is pretty cool.
Problem is that I didn't find a way to use custom font files
This is the code:
$img = new \Imagick;
$img->newImage($width, $height, new ImagickPixel('transparent'));
$img->setBackgroundColor(new ImagickPixel('transparent'));
$img->setFont($fontFile); // didn't work
$img->setPointSize($fontSize);
$img->setOption("font", $fontFile); // didn't work
$img->newPseudoImage($width, $height, "pango:<span font='".$fontName."' foreground='".$textColor."'>".$text."</span>"); // font='".$fontName."' - also didn't work
I also tried to install the font in ubuntu OS and use only the font name but that didn't worked either, as well as combining all the options above or some of them.
I found that question:
PHP Imagick don't use custom font > convert does. But he said he used "caption" instead of pango - which doesn't provide that cool "html" syntax and does not solve the Arabic issue.
Please - if you know any solution I will love you forever!
Thanks.
This question already has answers here:
Convert html to word /excel / powerPoint with PHP
(3 answers)
Closed 6 years ago.
I am doing html to doc conversion by php header function. Converted file is saved in doc format. But when I edit and save this, it creates a folder with same name as doc file name, which contains three files (themedata.thmx, filelist.xml, colorschememapping.xml).
I am using following code for doc generation.
header("Cache-Control: ");
header("Pragma: ");
header('Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Content-Disposition: attachment; filename="'.$filename.'.doc"');
I want to convert it in pure doc file, please help to fix this problem.
I have tried many other plugins to convert HTML to DOC for example :-
1. Pandoc :- It is converting html to docx but not picking style and images from html file.
2. PHPWord :- I didn't find any option in PHPWord to convert fully styled HTML in to docx. It is create docx by function (addTable, addCell) which I do not want.
3. htmltodocx.codeplex.com :- This plugin needs some specific style. It is not supporting all css.
4. unoconv :- Not found working.
5. Open office :- not found any functional command.
You cannot change a file format simply by changing the file extension. Do you think you can convert a PDF to a movie by changing the file name from .pdf to .mp4? I hope not, because it doesn't make any sense.
What's happening is that you're telling the browser to save data of an HTML file with a .doc extension. When you double click that file to open it, Word opens (because it's associated with .doc extensions). Word is stupid misleading forgiving enough to recognise that the file does not actually contain Word DOC data, but HTML, and it converts it for you on the fly without telling you.
When you then save this file, it creates an actual DOC/DOCX file for it; but apparently that doesn't happen cleanly and the container is breaking apart.
What you're seeing it a misbehaviour in Microsoft Word (on several levels).
What you should be doing to begin with is create an actual Word document, e.g. using https://github.com/PHPOffice/PHPWord.