Zend Framework with Handwritten Font - zend-framework

I am trying to use the Amatic Font from Google in my PDF File but it gives me an Error like below. Could that be because the Font Type? I have tested with Open Sans and it is working.
AH01071: Got error 'PHP message: PHP Fatal error: Uncaught exception
'Zend_Pdf_Exception' with message 'Unable to read version 4 table' in
/var/www/vhosts/httpdocs/main/zend/library/Zend/Pdf/FileParser/Font/OpenType.php:555\nStack
trace:\n#0
/var/www/vhosts/httpdocs/main/zend/library/Zend/Pdf/FileParser/Font/OpenType.php(121):
Zend_Pdf_FileParser_Font_OpenType->_parseOs2Table()\n#1
/var/www/vhosts/httpdocs/main/zend/library/Zend/Pdf/FileParser/Font/OpenType/TrueType.php(83):
Zend_Pdf_FileParser_Font_OpenType->parse()\n#2
/var/www/vhosts/httpdocs/main/zend/library/Zend/Pdf/Font.php(701):
Zend_Pdf_FileParser_Font_OpenType_TrueType->parse()\n#3
/var/www/vhosts/httpdocs/main/zend/library/Zend/Pdf/Font.php(615):
Zend_Pdf_Font::_extractTrueTypeFont(Object(Zend_Pdf_FileParserDataSource_File),
0)\n#4 /var/www/vhosts/httpdocs/main/zend/invoice.php(27):
Zend_Pdf_Font::fontWithPath('/var/www/vhosts...')\n#5 {main}\n\nNext
exception 'Zend_Pdf_Exception' wi...\n'
I am using this Script for my tests https://github.com/phpmasterdotcom/GeneratingInvoicesWithZendPdf/blob/master/public/invoice.php

What's happening is this: The Zend Framework code in OpenType.php explicitly checks the OS/2 table version of the font. Is it higher than 3, an exception is thrown. Your font has an OS/2 table version of 4 (which is the fifth version, there are at least 6 versions as far as I know).
Unfortunately, recent versions of the ZendPdf module (like here on GitHub) still don't seem to support version 4 or higher. So apart from looking for another pdf generator - that does support version 4 - I fear there's no clean solution.
You could try editing the framework code, but of course that's a bit shady. As an alternative, apparently it should be able to change that version and regenerate the font. See this post on the Tex forum (the post AFTER the accepted answer). If you choose that path, probably you'll find better guidance on that forum.
Sorry I can't offer a better solution, but maybe it helps you understanding what's going on.

Related

error in process sentinel: Could not start nREPL server: java.lang.NumberFormatException: Invalid number

I've looked at all of the similar questions on stack overflow. This one is different enough to warrant a separate question. Basically, I can't start a repl server because I get the error below. It's been pointed out that this is typically a dependency issue, but I'm updated, to my knowledge. What am I getting wrong here? Here's the full error:
error in process sentinel: Could not start nREPL server: java.lang.NumberFormatException: Invalid number: 0.8.3
at clojure.lang.LispReader.readNumber (LispReader.java:352)
clojure.lang.LispReader.read (LispReader.java:278)
clojure.lang.LispReader.readDelimitedList (LispReader.java:1398)
clojure.lang.LispReader$VectorReader.invoke (LispReader.java:1347)
clojure.lang.LispReader.read (LispReader.java:285)
clojure.lang.LispReader.read (LispReader.java:216)
clojure.lang.LispReader.read (LispReader.java:205)
clojure.lang.RT.readString (RT.java:1878)
clojure.lang.RT.readString (RT.java:1873)
clojure.core$read_string.invokeStatic (core.clj:3815)
clojure.core$read_string.invoke (core.clj:3805)
clojure.core$mapv$fn__8445.invoke (core.clj:6912)
clojure.core.protocols$fn__8159.invokeStatic (protocols.clj:168)
clojure.core.protocols/fn (protocols.clj:124)
clojure.core.protocols$fn__8114$G__8109__8123.invoke (protocols.clj:19)
clojure.core.protocols$seq_reduce.invokeStatic (protocols.clj:31)
clojure.core.protocols$fn__8146.invokeStatic (protocols.clj:75)
clojure.core.protocols/fn (protocols.clj:75)
clojure.core.protocols$fn__8088$G__8083__8101.invoke (protocols.clj:13)
clojure.core$reduce.invokeStatic (core.clj:6828)
clojure.core$mapv.invokeStatic (core.clj:6903)
clojure.core$mapv.invoke (core.clj:6903)
leiningen.update_in$parse_args.invokeStatic (update_in.clj:13)
leiningen.update_in$parse_args.invoke (update_in.clj:9)
leiningen.update_in$update_in.invokeStatic (update_in.clj:36)
leiningen.update_in$update_in.doInvoke (update_in.clj:24)
clojure.lang.RestFn.applyTo (RestFn.java:146)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core$apply.invokeStatic (core.clj:667)
clojure.core$apply.invoke (core.clj:660)
leiningen.core.main$partial_task$fn__7331.doInvoke (main.clj:284)
clojure.lang.RestFn.applyTo (RestFn.java:139)
clojure.lang.AFunction$1.doInvoke (AFunction.java:31)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invokeStatic (core.clj:667)
clojure.core$apply.invoke (core.clj:660)
leiningen.core.main$apply_task.invokeStatic (main.clj:334)
leiningen.core.main$apply_task.invoke (main.clj:320)
leiningen.core.main$resolve_and_apply.invokeStatic (main.clj:343)
leiningen.core.main$resolve_and_apply.invoke (main.clj:336)
leiningen.core.main$_main$fn__7420.invoke (main.clj:453)
leiningen.core.main$_main.invokeStatic (main.clj:442)
leiningen.core.main$_main.doInvoke (main.clj:439)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.lang.Var.applyTo (Var.java:705)
clojure.core$apply.invokeStatic (core.clj:665)
clojure.main$main_opt.invokeStatic (main.clj:514)
clojure.main$main_opt.invoke (main.clj:510)
clojure.main$main.invokeStatic (main.clj:664)
clojure.main$main.doInvoke (main.clj:616)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.lang.Var.applyTo (Var.java:705)
clojure.main.main (main.java:40)
EDIT:
So I've gotten farther on this problem and I think I'm down to the last little issue or two. The file that is being pulled that causes the java.lang.NumberFormatException is cider.el which you can finder in your emacs.emacs.d\elpa\cider-[VERSION NUMBER, in my case 20210104.915]. You open your cider.el file and on line 392/393, in this version, you'll find:
(cider-add-to-alist 'cider-jack-in-dependencies
"nrepl/nrepl" "0.8.3")
So changing this line, recompiling it, and reloading emacs gets the number throwing the java.lang.NumberFormatException to change to whatever I changed it to (recompile by using byte-compile-file, hitting enter, then passing it the address of the document). Adding another set of double quotes gets a null value error of sorts (obviously) and doing any type of backslashing for exceptions and sort doesn't seem to solve the issue. So, since the few related posts (though with much less detail) seem to hint at changing the version number, I'm going to have to assume that I have to do that. What version number would work best here?
TEMP SOLUTION SO FAR:
start a repl with "lein repl" in command line and connect to it manually using the connect command "cider-connect" and specifying the localhost (I started the repl in same directory as project and it detected it easily). This is not good enough for me as a permanent solution but gets me up and going temporarily until a better solution is found.
PERMANENT SOLUTION:
see below
Look at your dependencies. I had an issue where my java jdk was basically broken (java's fault, not mine, in so far as the code is concerned). I ended up using the latest OpenJDK (number 15). That worked. If you get lots of java specific type errors and those errors change with the versions that you're using, then consider updating your java jdk. I was using LTE versions before and the latest fixed it.

Coldfusion/Lucee Encoding Issue When Using EncodeForHTML

Running into an issue when using EncodeForHTML for certain characters (Emojis in this case)
The text in this case is:
⌛️a😊b👍c😟 💥🍉🍔 💩 🤦🏼‍♀️🤦🏼‍♀️🤦🏼‍♀️ 😘
Now if I just a straight output
<cfoutput>#txt#</cfoutput>
It displays correctly, no issues, but if I use EncodeForHTML first
<cfoutput>#EncodeForHTML(txt)#</cfoutput>
I get this
⌛️a��b��c�� ������ �� ����‍♀️����‍♀️����‍♀️ ��
I tested it with EncodeForXML & esapiEncode as well to be sure; all are giving me the same result.
I've verified the encoding settings in Lucee are UTF-8, and the meta charset tag is also set to UTF-8. I can't find any documenation re: EncodeForHTML saying if it make any changes to the character encoding, if it requires the character encoding to be something specific, or if it has any known issues with emojis or certain code points.
I appreciate any help or clarification anyone can provide.
Edit: Thank you everyone. Wish I could accept multiple answers.
I was required to sanitize emojis in order ensure that third-party content was cross-compatible with external services. Some of the content contained emojis and was causing export/import problems. I wrote a ColdFusion wrapper for the emoji-java library to identify, sanitize and convert emojis.
https://github.com/JamoCA/cf-emoji-java
For example, the parseToAliases() function "replaces all the emoji's unicodes found in a string by their aliases".
emojijava = new emojijava();
emojijava.parseToAliases('I like 🍕'); // I like :pizza:
To "encode" you could use either the parseToHtmlDecimal() or parseToHtmlHexadecimal() functions prior to using EncodeForHTML().
emojijava = new emojijava();
test = emojijava.parseToHtmlDecimal('I like 🍕'); // I ❤️ 🍕
EncodeForHTML(test);
At the time of this writing, ColdFusion's latest version is 2018 update 9
In turn, it uses ESAPI 2.1.1
Recent release notes don't mention Emoji,
https://github.com/ESAPI/esapi-java-legacy/tree/develop/documentation
But they do mention in Pull request 413
"Fixing ESAPI's inability to handle non-BMP codepoints."
This dates from 2017
https://github.com/ESAPI/esapi-java-legacy/pull/413
So based on all this information, I would recommend doing both of the following
Try using ESAPI directly. This is how it was done before ESAPI was added to CF. This issue may or may not still exist in ESAPI
Put in a ticket with Adobe to update this library.
Yes, ESAPI 2.2.0.0 addressed the issue of not correctly encoding non-BMP characters (see https://github.com/ESAPI/esapi-java-legacy/issues/300) as part of PR #413 that James mentioned above.
But I just uploaded release ESAPI 2.2.1.0-RC1 (release candidate 1) to Maven Central early this morning and hope to have an official 2.2.1.0 release out by next weekend, so if you are going to put in a ticket with Adobe for fix this with an updated version of ESAPI, I'd wait another week and then tell them to update to 2.2.1.0.

Why do I get a message saying 1.not.found.as.a.resource?

What might cause
new Font(Font.HELVETICA, 11f, Font.BOLD)
or
BaseFont.createFont(BaseFont.HELVETICA, 'Cp1252', BaseFont.NOT_EMBEDDED)
to start returning the following??
com.itextpdf.text.DocumentException: No message found for 1.not.found.as.resource
itext 5.5.6 jar on Max OSX 10.10
It seems that you are not using the "pre-canned" jar, but that you have created your own jar. That self-made jar only contains the Java class files. It misses resources such as the language (.lng) and the Adobe Font Metrics (.afm) files.
If the above assumption is wrong, then at least this is right:
Instead of the actual error message, you get the key to an error message that is stored in a .lng file: 1.not.found.as.resource. This key is used to find the actual error message in the language of your OS (English, Dutch and Portuguese are supported; the default is English).
The actual error message (should en.lng be found) would have been: "Helvetica not found as a resource" (the 1 in 1.not.found.as.resource is a placeholder). This message tells you that the file Helvetica.afm can't be found. This file contains the metrics of every glyph in the font Helvetica (regular). Without those metrics, you can't create a proper PDF.
This explains what happens. Your question doesn't contain sufficient information to explain why it happens. All of this shouldn't be a problem when using the correct jar with a JDK that knows how to read resources from a jar. The fact that you write "What might cause ... to start returning the following" indicates that it has worked for you before. Think of what you have changed between the last time it worked and the first time it stopped working (e.g. changing the OS, changing the JVM,...). That will probably be the culprit.

Stata error when using new commands

I need some help with Stata. I'm not sure if this is the right forum, but hopefully somebody can help me.
The problem occur, when I want to use new commands in stata. I will explain it with an example: command outreg. I assume the problem is the version.
Stata Details:
Version 10.1
Unlimited-user Stata for Windows (network) perpetual license (decompressed in C:\Program Files (x86)\Stata)
I downloaded the command ssc install outreg
I tried the new command with the example given here:
http://www.ats.ucla.edu/stat/stata/faq/outreg.htm
After execution, the following error occur, after outreg using test.doc, nolabel replace
MakeSmat(): 3499 _CColJoin() not found
CalcStats(): - function returned error
<istmt>: - function returned error
Stata.com also provide a solution for the problem:
http://www.stata.com/statalist/archive/2011-07/msg01018.html but a restart of stata doesn't work for my problem.
The necessary library (l_cfrmt described in the stata.com link) is also available:
. mata : mata query
Mata settings
set matastrict off
set matalnum off
set mataoptimize on
set matafavor space may be space or speed
set matacache 400 kilobytes
set matalibs lmatabase;lmataado;lmataopt;l_cfrmt
set matamofirst off
But when I search for the usage of the library l_cfrmt (which is necessary for outreg) there occur the following error-message:
. mata : mata desc using l_cfrmt
c:\ado\plus\l\l_cfrmt.mlib from a more recent version of Stata
It looks, if the version, which I loaded via ssc is not compatible with the Version 10.1 of Stata.
Does somebody have any idea how to solve this problem? I search for a few hours now, but I did't find any possible solution.
Regards,
Michael
First, the code you found on the ucla website for -outreg- is not correct -- John Gallup has since made many changes to the latest version of -outreg-, one of which affects your example. (ignoring your mata issue for a moment) This code should be modified to this in order to make it run:
**install latest outreg
ssc install outreg, replace
use http://www.ats.ucla.edu/stat/stata/notes/hsb1, clear
regress read write
outreg using test.doc, novarlabel replace
the code above works on my machine with an updated version of Stata 12 MP and updated -outreg- version 4.12.
Regarding the mata error: It might be the case that the newest -outreg- just might not work with Stata 10.1 - but I wouldn't give up yet. First, make sure your Stata is fully updated (-update query- and -update all-).
Second, follow the advice of the author of -outreg- in this Statalist thread:
http://www.stata.com/statalist/archive/2011-07/msg01014.html
Finally, if you do have a missing mata component/library, as that thread hints at, and cannot follow this advice to correct it, then consider re-installing Stata and/or contacting Stata tech support.

Enterprise Library 4: logging block flat file

I am having problem creating log entry to a text file. Here is my logging configuration in my ASP.net app.
and here is my vb.net code
Try
db.ExecuteNonQuery(cmd, tr)
tr.Commit()
result = True
Catch ex As Exception
Dim entry As New LogEntry()
entry.EventId = 11
entry.Message = ex.Message
entry.Categories.Add("General")
Logger.Write(entry)
tr.Rollback()
End Try
All the tutorial and example that i found so far are based on older version of Enterprise Library. I'm using Enterprise Library 4. Does anyone know what i'm doing wrong? Is it my code or the configuration? Where can i find more tutorial on Enterprise Library version 4. I tried to follow the quick start that it come with but i can't make head or tail.
its a basic tutorial on using enterprise library 4.1
http://blog.accentient.com/EnterpriseLibraryLogging101.aspx
btw, to get mine to work, i had to change all the PublicKeyToken's to = null
otherwise the web.config didnt validate, gl