Make "Enable/Disable Unicode Mode" optional?
pillow - September 3, 2008 - 14:22
| Project: | Printer, e-mail and PDF versions |
| Version: | 6.x-1.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
On my site, print_pdf module generate very big file(at least 6M) even if there are only a few words in page. I think that's because the font I set in print_pdf module configuration page is too large(5785KB download from http://joomlacode.org/gf/project/pdffonts15/frs/?action=FrsReleaseBrowse...).
I found
All TCPDF fonts must be embedded on the PDF document, unless you are using standard fonts whith Unicode mode disabled
in tcpdf_php4/fonts/utils/README.TXT, is it possible to make "Enable/Disable Unicode Mode" optional in print module?
PS:My site is based on Chinese, is there anyway to avoid Chinese character display problem if not specify a Chinese font?

#1
Hi,
I can, but I am not sure that it will do anything.
Please change the line:
$pdf = new PrintTCPDF($orientation , 'mm', $print_pdf_paper_size, TRUE);
to
$pdf = new PrintTCPDF($orientation , 'mm', $print_pdf_paper_size, FALSE);
And try to check if anything useful comes out of the PDF generation (I truly doubt it).
João
#2
It doesn't work, seems I have to try the others~
#3
Just some more information, the reason why disabling Unicode is probably going to give you lots of problems is that:
1. Drupal's content is in Unicode (http://drupal.org/node/8408)
2. Your site is not in English, so non-Unicode fonts will probably display your site's content as random letters. I doubt that the PDF core fonts include Chinese characters (try specifying helvetica as the font just to make sure).
And I think that your solution will probably be:
The "Reducing the Size of TrueType Fonts" section at the end of this page:
http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf_fonts
However, as long as TCPDF embeds the complete font and not only the subset being actually needed by the generated document, I think that any encoding subset for Chinese will always be too large to be of practical use... Maybe you can ask TCPDF's author to work on that..
João
#4
After some search work, I found:
2. I don't think core fonts includes chinese fonts. It's mentiond in tcpdf_php4/fonts/utils/README.TXT as:
TCPDF's Core (standard) fonts are:
* courier : Courier
* courierb : Courier Bold
* courierbi : Courier Bold Italic
* courieri : Courier Italic
* helvetica : Helvetica
* helveticab : Helvetica Bold
* helveticabi : Helvetica Bold Italic
* helveticai : Helvetica Italic
* symbol : Symbol
* times : Times New Roman
* timesb : Times New Roman Bold
* timesbi : Times New Roman Bold Italic
* timesi : Times New Roman Italic
* zapfdingbats : Zapf Dingbats
Specifying helvetica make chinese character in the file generated by tcpdf display as "?????"
What give me hope is the chinese site page http://www.linux-ren.org/modules/news/article.php?storyid=362. It can generate normal size file from oritinal html page, that's meaning no fonts are embeded.
It seems that it is build by xoops, and use a module called "Pdf System" http://webscripts.softpedia.com/script/Modules/phpWebSite-Modules/Pdf-Sy...
I'm not sure how the content encodeed in XOOPS, but I think right size chinese pdf document is practicable. I'll try the following:
1.ask if TCPDF's author would like to add the core fonts support for Chinese
2.at the same time, could we check for Pdf-System-for-Xoops' code for reference?
#5
Hi,
PDF for xoops is done with the Smartsection module (http://smartfactory.ca/modules/wfdownloads/singlefile.php?cid=2&lid=103) which includes FPDF, which saw no release since 2004.. Well, except for the 1.6 release a month ago...
Anyway TCPDF is also based on FPDF, so it should be much better than FPDF.
As to checking the Smartsection module's code for reference... Feel free to do it.
This needs to be handled by the PDF library, so in the end it must always be corrected by TCPDF. I am not maintaining TCPDF so I can't help you further than that..
Have you tried the non-Unicode mode as I explained in #1?
João
#6
Actually, I was wrong.. They're using the News module (http://xoops.instant-zero.com/modules/mydownloads/singlefile.php?cid=2&l...)..
It seems that this makepdf.php is repeated in all XOOPS modules. The original source for the makepdf.php seems to be the newbb module (which is developed by the XOOPS core team).. It's GPL and there's a chinese.php file in there that probably is doing a lot of work to make the PDF generation work. Maybe you can ask TCPDF's author to take a look at what the XOOPS developers did and adapt it to TCPDF.
And the linux-ren.org site is not Unicode encoded.. It uses the GBK encoding, which probably helps when generating the content..
João
#7
I have tried non-Unicode mode yestoday already, the reply in #2 is the result unfortunately.
As you metioned, days search tell me the same thing, a lots php pdf derive from fpdf.
It seems the only way is hoping tcpdf's maintainer's help now. I have submited a feature request, and will forward any advance back to here.
#8
Hi,
I had missed the #2 reply. I take it that makes the need to 'enable/disable unicode' irrelevant.
As such, I am closing the issue.
Best of luck with TCPDF's author.
João
#9
Excuse me for change Status to active just for you can know this update, please change it to closed anytime.
I got author's reply in following page, I'm not sure if TCPDF's author will do this working. If he won't, would you like to give me some guidace or advice?
https://sourceforge.net/tracker/index.php?func=detail&aid=2093393&group_...
#10
Hi,
From what he has written, he knows what needs to be done, but I don't think he will do it soon. Since it is a lot of work, I expect that he will either take a long time to do it for free or he will do it fast when someone pays him to do it. Your best option is possibly to try to find a good PHP programmer in China and ask him to try to see what can be done to create a solution like XOOPS and adapt it to TCPDF.
João
PS: Please don't reopen the issue anymore. Send me direct mails through my user's contact form in Drupal.org.
#11
thanks for your great help~
#12
Just a final note.
Take a look at this: http://yukihiro.nakadaira.googlepages.com/mbtcpdf.zip
It seems to be something which extends TCPDF to handle CJK encoding, somehow.
Maybe you can get in touch with Yukihiro Nakadaira - yukihiro.nakadaira at gmail dot com - and ask him to explain what this is doing. Maybe he and the author of TCPDF can cooperate in getting this into one of the next TCPDF releases.
João
#13
I left a reply to TCPDF's author a few days ago on https://sourceforge.net/tracker/index.php?func=detail&aid=2093393&group_....
But he hasn't responed yet, all I can do is wait now~I think.
#14
There are some change in latest released version of TCPDF TCPDF 4.0.026_PHP4 including the following content by change log(https://sourceforge.net/project/shownotes.php?release_id=626880&group_id...):
4.0.025 (2008-09-15)
- _putcidfont0 function was improved to include CJK fonts (Chinese, Japanese, Korean, CJK, Asian fonts) without embedding.
- arialunicid0 font was added (see the new example n. 38).
- The following Unicode to CID-0 tables were added on fonts folder: uni2cid_ak12.php, uni2cid_aj16.php, uni2cid_ag15.php, uni2cid_ac15.php.
Now the font is not embeded into file anymore, but the default size of image is zoomed out but not the original size, is there any chance to change this?
#15
Hi,
Congratulations in getting CJK support into TCPDF.. I think if it wasn't you, the patch by Yukihiro Nakadaira would still be left unnoticed by Nicola.
Now, as to the problem with the image:
1. I don't understand your question. Can you provide an example of the original page and the generated PDF?
2. Let's not mix the two things. Please create a new issue for the image issue, provide the information I requested there, and we discuss that in that issue. This issue was mostly about the CJK embedding and that has now been fixed.
João