Forum How do I...?

Cryptic Error

jimbrooking
I am trying to print a fairly simple document (Prince version 10) and getting an error message:

Type Error: null value is not an object

I've attached a JPG of the screen showing the error message and the file it's trying to convert. I can provide he attached CSS if needed.

As you can see, line 10 is a CSS declaration. What is the real problem?

Thanks.
  1. new_directory.xhtml10.5 kB
    The XHTML file
  2. screen.2.jpg253.6 kB
    Shows error message and location
dauwhe
Running the HTML in the browser I see a console error from the JS.

There seems to be a problem with document.getElementById('ToCbox').appendChild(ToC);

If I add a div with id="ToCbox" to the HTML, then I don't get the error from Prince or the browser.

Dave

jimbrooking
Well "Doh"!

Meaning "stupid me". I should have thought of that. Thanks very much, Dave. Funny - the code that adds "ToCbox" as an id to the <body> tag appears below, lines 44-45, so maybe a timing issue. I can deal with that.

Thanks again!

Jim
mikeday
Sorry about the line numbers, these are currently relative to the beginning of the <script> element, not the entire file, which causes much confusion. We will fix this in a future release.
jimbrooking
Here's another, same heading.

I'm running Prince on a server using the PHP Prince class. I am trying to move to a different hosting co, and I know the new one is set up slightly differently. But I have finally gotten it all to at least get loaded, but am seeing a warning (that also appears on the desktop ) and an error (not appearing on the desktop) with no line numbers or other hints:
PDF Conversion Messages - PDF Generation Failed
Array(2)
(
|  ['0']=>Array(3)
|  (
|  |  ['0']=String(3)"wrn"
|  |  ['1']=String(48)"/home/fearrin1/public_html/newprint/printing.css"
|  |  ['2']=String(29)"failed to parse all CSS rules"
|  )
|  ['1']=>Array(3)
|  (
|  |  ['0']=String(3)"err"
|  |  ['1']=String(0)""
|  |  ['2']=String(18)"no available fonts"
|  )
)

I can get along with the warning - the CSS file is 660+ lines long, so will try to devine that problem later - but I wonder what the error is telling me and how I might correct it.

Thanks!
mikeday
The error is telling you that there are no available fonts. :D

You will need to install some fonts, make sure fontconfig is installed if it is a Linux server, or edit the fonts.css file to point to the fonts with @font-face rules, as described here.

By the way, our latest builds of Prince include a new CSS parser which provides much more informative syntax error messages, so you might like to try that to quickly find any issues with your CSS file.
jimbrooking
Well, interesting that my new hosting co. doesn't have any fonts installed. Everything else I've tested on my Joomla-based site seems to work as expected. I will have to dig around to see how that works.

You are soooo quick to reply to these posts. Are you a bot? ;-)
mikeday
Since many hosting servers don't run any desktop apps, they don't bother installing fonts. If you have root access then it's usually easy to install some with apt-get on Ubuntu or yum on CentOS. Otherwise you have to copy the .ttf files into your home directory somewhere and then run "prince --scanfonts" on them to generate a CSS file with @font-face rules that you can use.

Not a bot, just eager to please. :)
jimbrooking
Mike- I have fount and up-loaded 4 ariel*.ttf files. The documentation about "prince --scanfonts" isn't clear about how to specify the directory or file names. Could you give an example for files saved in, say."/home/fearrin1/public_html/images/fonts/arial*.ttf"?

Thanks. Sorry to be a pest.
mikeday
Yes, just put the file names on the command-line:
prince --scanfonts /home/fearrin1/public_html/images/fonts/arial*.ttf > myfonts.css