Forum


Replies: 20   Views: 10753
Greek and hebrew
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by rswoods_  · 16-11-2015 - 20:48

Deleted by rswoods_ · 16-11-2015 - 22:13

Posted by shroom  · 16-11-2015 - 21:04

I stupidly registered with my Yahoo email address as my username, and cannot change it....   So I deleted the original post and reregistered..   I see that even when you delete a post, the username for the deleted post still shows up.  Oh well.  Is it possible for a moderator to completely delete the remnants of that post?

Anyway, here's the original post:

I am experimenting with the trial version of PHPDocx.  We have a website that has some Greek and Hebrew words in it, like this:

The Hebrew word “man,” ish(#0376 [legit Hebrew word])....

The Greek word is epithumia (#1939 [legit Greek word]), and...

When I paste this HTML in the online demo, the Word doc that is generated displays these characters correctly.  On the test page I'm working on, they're coming out as:

The Hebrew word “man,” ish(#0376 Ã—ÂÂִיש×ÂÂ)....

The Greek word is epithumia (#1939 Ã¡Â¼ÂÂÀιθÃÂÂÂ…ÃŽ¼á½·ÃŽ±), and...

I'm sure I'm missing something simple, but I can't figure out what it is.  In phpdocxconfig.ini, I have tried seting encode_to_UTF8  to both 'true' and 'false', no difference.  I have also tried including "<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />".

What am I missing?

Thanks

 

Posted by admin  · 17-11-2015 - 12:24

Hello,

We have change your previous account. About your issue please check that PHP Tidy is enabled and running, it's the most common issue when working with HTML.

Regards

Posted by shroom  · 17-11-2015 - 16:08

Thanks for munging my email.  It was dumb of me.

I enabled php tidy, and the Greek and Hebrew are now displaying, but "smart quotes" (&ldquo; and &rdquo;) are being rendered as "?"

1:1. ?servant.? The Greek is doulos (#1401 [good Greek word])...

The word "servant" is wrapped by smart quotes.

...fix one thing, break another. :)

Thanks.

Posted by shroom  · 17-11-2015 - 17:14

I added " 'preserve-entities' => 1" to the config array used by PHP Tidy in parserhtml.cls.php on line 418 and now it works.  I am seeing all Hebrew and Greek words rendered correctly, also smart quotes.

Was this -really- the right fix?

Posted by admin  · 17-11-2015 - 18:16

Hello,

You can escape the data manually use a PHP function or change the config array directly. We recommend you the first aproach to don't change the library.

Regards.

Posted by shroom  · 17-11-2015 - 21:16

Pardon my ignorance, but how can I escape a &ldquo; (and all the other html entities) that are in all the html I need to convert manually so PHP Tidy will not convert them into unprintable characters?  And when you say "change the config array directly", are you referring to the Tidy config file as referenced in php.ini?  If not, how can I change the config array directly?

...I do understand that it's not wise to change the PHPDocx library, but it was the one thing that worked...

Thanks

Posted by admin  · 18-11-2015 - 07:37

Hello,

For further support please purchase a license and contact with us. The trial package is crypted and free support is limited to doubts and general questions.

Regards.

Posted by shroom  · 18-11-2015 - 12:50

I am still trying to figure out if phpdocx will work for us.  Also, if we do purchase a license, it will be for the live website which has a different domain from the dev site.  According to your licensing scheme, we would apparently need to purchase two licenses.  One license to get support while developing on the dev site, and another license for when it's pushed to the live site.  Is that how it works?

I do want to say that from what I can see so far, phpdocx seems like it will work.  It's very full-featured and overall does a very good job with importing HTML.  My plan was to get it all working on the dev site using the demo version, then purchase a license for the live site when it's pushed live.  Is that not doable?

I hope you can offer some assistance. 

I have a couple of issues that so far I cannot solve.  One is the topic of this thread, how to have phpdocx correctly process both foreign languages and HTML entities.  Another is that importStyles() with "$type=replace" does not seem to work, the styles are neither replaced nor imported.  "$type=merge" does work.  No matter what I try I cannot get a doc to NOT have all the PHPDOXC styles.  Finally, when using embedHTML() with strictWordStyles=>true, I cannot get the styles to apply to anything other than direct HTML tags or <p> tags with a class.  I so far cannot get them to apply to classed or id'ed <span> or <div> tags.  I'm still messing with this last one..

Thanks

Posted by admin  · 18-11-2015 - 15:02

Hello,

All licenses allows to use the library on the purchased subdomain/domain/IP, localhost and private networks (classes A, B and C). For example you can use a Corporate license in a whole subdomain and all its subdomains (such as test.domain.com, doc.domain.com, intranet.domain.com...), beside localhost and private networks.

If you need a different subdomain/domain there's a 50% off offer, please check the banner on http://www.phpdocx.com/updates.

About your issues we recommend you to check the included examples within the package and the documentation and samples available on the API pages. All properties are working perfectly as described in the documentation.

Regards.

Posted by shroom  · 18-11-2015 - 18:15

So basically, you will not help unless I spend $450 for one professional license and one developer license?  (the dev site is on a different domain, not a subdomain of the live site)

>>All properties are working perfectly as described in the documentation.

Believe me, I have been poring through any documentation I could find.

This works, the styles are merged:
$docx->importStyles($docroot.'/includes/REV_styles.docx', $type= 'merge',
     array('BookTitle',
             'BookChapter',
             'VerseHeading',
             'VerseHeadingMicro',
             'SectionHeading',
             'BlockQuote',
             'FootNote'));

This does not work, the styles are not imported and the PHPDOCX styles are not replaced:
$docx->importStyles($docroot.'/includes/REV_styles.docx', $type= 'replace');

And when the styles are merged successfully, and I do this:

$docx->embedHTML($html, array('strictWordStyles' => true,
'wordStyles' => array('<h2>' => 'BookTitle',
                               '<h3>' => 'BookChapter',
                               '.verseheading' => 'VerseHeading',
                               '.verseheadingmicro' => 'VerseHeadingMicro',
                               '.sectionheading' => 'SectionHeading',
                               '.blockquote' => 'BlockQuote',
                               '.footnote' => 'FootNote'
                               )));
 

If $html has <div class="blockquote">some text</div> the BlockQuote style is NOT applied.

If $html has <p class="blockquote">some text</p> the BlockQuote style IS applied.

The imported styles are only applied to classed <p> tags.

Anyway, thanks for the help you did provide.

Posted by admin  · 18-11-2015 - 18:32

Hello,

The library is working perfectly as explained on the documentation.

The trial package is crypted and can't be debugged, so there's no support of the trial package but for general questions and minor doubts. We recommend you to run the included examples to check if the library is working fine.

If the styles are not being applied is because in your script or DOCX there must be something wrong: maybe mispelled styles names, wrong styles in the DOCX source... We'd need to check it directly.

We're happy to help, but to check custom scripts a license is needed.

About environments, as explained before, all licenses allows to use the library in localhost and private networks (classes A, B and C) beside the purchased subdomain/domain/IP. These are the environments we consider for development.

Regards.

Posted by shroom  · 18-11-2015 - 19:55

>> We recommend you to run the included examples to check if the library is working fine.

In examples/LayoutAndGeneral/importStyles/sample_1.php, the file works fine as written:
$docx->importStyles('../../files/TemplateStyles.docx', 'merge', array('crazyStyle'));

The file has the comment:
//You may also import a complete XML style sheet by
//$docx->importStyles('../files/TemplateStyles.docx', $type= 'replace');

I replaced this line:
$docx->importStyles('../../files/TemplateStyles.docx', 'merge', array('crazyStyle'));

with this:
$docx->importStyles('../../files/TemplateStyles.docx', $type= 'replace');

The styles were not imported.

>> If the styles are not being applied is because in your script or DOCX there must be something wrong: maybe mispelled styles names, wrong styles in the DOCX source...

As I noted, when I "merge" the styles from my template, they work fine, so nothing is misspelled and they are not wrong.  When I "replace" the styles, nothing is imported.

Also:
I added this line into sample_1.php just below the $docx->addText() line:
$docx->embedHTML('<p>new paragraph</p>
                  <div class="crazystyle">this is a div class="crazystyle"</div>
                  <p class="crazystyle">this is a paragraph class="crazystyle"</p>',
                 array('strictWordStyles' => true,
                       'wordStyles' => array('.crazystyle' => 'crazyStyle')
                 ));

The crazyStyle is applied to the <p class="crazystyle">, but not to <div class="crazystyle">.  This is the exact behavior I am seeing in my code.

Thanks.

Posted by shroom  · 19-11-2015 - 17:23

Do you have an example where this:

$docx->importStyles('whatever.docx', $type= 'replace');

actually works?

Do you have an example where an imported style assigned to '.myimportedclass' can be applied to a <div class="myimportedclass"> or <span class="myimportedclass">?  (please see previous post)

There are no examples included with the trial version of PHPDocx that demonstrate these two things.

Thanks.

Posted by admin  · 19-11-2015 - 17:34

Hello,

There're more examples, but only available for purchases licenses.

Sorry but the trial license doesn't include any support but for general questions and minor doubts.

Regards.

Posted by shroom  · 19-11-2015 - 19:25

So it's not possible to find out if the software will do what the documentation says it will do without buying it?

Do you offer a money back guarantee?  If I purchase a license and find out that PHPDocx will not meet our needs, is the purchase price refundable?

Thanks.

Posted by admin  · 20-11-2015 - 07:52

Hello,

You can read all the information about Returns and refunds policy on http://www.phpdocx.com/faqs.

Regards.

Posted by shroom  · 15-12-2015 - 15:31

Since we now own a registered copy of phpdocx, I would like some assistance with the two questions I asked above.

1) Regarding PHPTidy, what are you referring to when you say I can change the config array directly?

2) You stated that there are more examples of using importStyles() in the licensed version of phpdocx.  Where are these examples located?  All I can find are the same two samples included with the trial version.  I am so far unable to successfully "replace" styles.  Even in the included example, if I change "type=merge" to "type=replace", it does not work, nothing is imported, let alone replaced.  What is required in order for "replace" to work?

Thanks.

Posted by admin  · 15-12-2015 - 17:09

Hello,

Some styles from PHPDOCX can't be overwriten using the method importStyles due to compatibility when adding some special content. This should be the problem you have found.

To overwrite all styles we recommend you to use your own template using the CreateDocxFromTemplate class instead of create the document from scratch (you can use an empty template and add content to it) overwritting the styles you don't want and/or set your base template when you instanciate CreateDocx; this is the signature of the constructor:

/**
     * Construct
     *
     * @access public
     * @param string $baseTemplatePath. Optional, basicTemplate.docx as default
     * @param $docxTemplatePath. User custom template (preserves Word content)
     */
    public function __construct($baseTemplatePath = PHPDOCX_BASE_TEMPLATE, $docxTemplatePath = '')

About Tidy we meant that this PHP extension has options to config it if needed in the INI file of the extension.

Anyway we're checking in detail the replace option to improve it and add new examples. The most important advantage of the PRO package is that unlike the trial one it's not crypted.

Regards.

Posted by shroom  · 15-12-2015 - 19:43

Thanks for responding.  I will mess with specifying $baseTemplatePath.