Troubleshooting PrinceXML

I am having the hardest time getting PrinceXML to work. I have it installed on my Ubuntu server. Using the command line I can convert documents using a command like this:

/usr/bin/prince home/ubuntu/Writing-in-College.html -o home/ubuntu/writing-in-college.pdf

So I know my path to prince is ‘/usr/bin/prince’ and I know it works.

So in my wp-config.php I have added the lines:

/* Converters */
define( ‘PB_PRINCE_COMMAND’, ‘/usr/bin/prince’);
define( ‘PB_XMLLINT_COMMAND’, ‘/usr/bin/java -jar /usr/bin/xmllint’);
define( ‘PB_EPUBCHECK_COMMAND’, ‘/usr/bin/java -jar /usr/bin/epubcheck/epubcheck.jar’);
define( ‘PB_KINDLEGEN_COMMAND’, ‘/usr/bin/kindlegen/kindlegen’);

But pressbooks is still telling me that I don’t have prince installed. What should I try next?

I do not have a license, but I am just doing this for non-commercial purposes, so I was ok with having a watermark on the first page.
http://www.princexml.com/howcome/2014/faq/#non-commercial

Are there any PHP packages or dependencies that I might need to install?

System Information

Root Blog Info

Root Blog ID: 1
Root Blog URL: http://oer.ed-beck.com/

Browser

Platform: OS X
Browser Name: Chrome
Browser Version: 65.0.3325.162
User Agent String: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36

WordPress Configuration

Network URL: http://oer.ed-beck.com/
Network Type: Subdirectory
Version: 4.9.4
Language: en_US
WP_ENV: production
WP_DEBUG: Enabled
Memory Limit: 64M

Pressbooks Configuration

Version: 5.1.0
Root Theme: Aldine
Root Theme Version: 1.1.0

Pressbooks Dependencies

Epubcheck: Installed
Kindlegen: Installed
xmllint: Not Installed
PrinceXML: Not Installed
Saxon-HE: Not Installed

Must-Use Plugins

hm-autoloader.php: n/a

Network Active Plugins

Candela LTI: 0.1
Candela Thin Exports: 0.1
GitHub Updater: 7.5.0
H5P: 1.10.1
Hypothesis: 0.5.0
LTI: 0.1
Pressbooks: 5.1.0
Textbooks for Pressbooks: 4.0.2

Root Blog Active Plugins

Inactive Plugins

Akismet Anti-Spam: 4.0.3
CC Export for Pressbooks: 0.2.1
Docraptor for Pressbooks: 2.2.1
Hello Dolly: 1.6
mPDF for Pressbooks: 3.1.1
Wp Show Site ID: 1.0.0

Server Configuration

PHP Version: 7.0.28-0ubuntu0.16.04.1
MySQL Version: 5.7.21
Webserver Info: Apache/2.4.18 (Ubuntu)

PHP Configuration

Safe Mode: Disabled
Memory Limit: 500M
Upload Max Size: 2000M
Post Max Size: 2000M
Upload Max Filesize: 2000M
Time Limit: 30
Max Input Vars: 1000
URL-aware fopen: On (1)
Display Errors: On (1)

PHP Extensions

OPcache: Zend
XDebug: Disabled
cURL: Supported
cURL Version: 7.47.0
imagick: Installed
xsl: Installed

Hi @beckej, what is the output of /usr/bin/prince --version?

/$ usr/bin/prince --version
prince: /usr/lib/prince/license/license.dat: error: can’t open input file: No such file or directory
prince: warning: failed to load external entity “/usr/lib/prince/license/license.dat”
prince: /usr/lib/prince/license/license.dat: warning: could not load license
Prince 20171214
Copyright 2002-2017 YesLogic Pty. Ltd.
No license

Ah, so that’s the issue. You should have a non-commercial license file installed. Did you use our Ansible role? It lets you specify a local path to a license file:

You can download a .tar.gz file from Prince, e.g. https://www.princexml.com/download/prince-11.3-ubuntu16.04-amd64.tar.gz, and use the license.dat file from there:

09 AM

But, the default license file should be installed… not sure why it isn’t in your case. Can you run ls -al /usr/lib/prince and share the output? Should have something like the following:

total 0
drwxr-xr-x   12 ubuntu  admin    384 10 Jul  2017 .
drwxr-xr-x  446 ubuntu  admin  14272 25 Dec 14:09 ..
drwxr-xr-x    3 ubuntu  admin     96 10 Jul  2017 bin
drwxr-xr-x    3 ubuntu  admin     96 10 Jul  2017 dict
drwxr-xr-x   13 ubuntu  admin    416 10 Jul  2017 dtd
drwxr-xr-x    3 ubuntu  admin     96 10 Jul  2017 etc
drwxr-xr-x   58 ubuntu  admin   1856 10 Jul  2017 hyph
drwxr-xr-x    6 ubuntu  admin    192 10 Jul  2017 icc
drwxr-xr-x    4 ubuntu  admin    128 10 Jul  2017 lib
drwxr-xr-x    3 ubuntu  admin     96 20 Jul  2015 license
drwxr-xr-x    4 ubuntu  admin    128 10 Jul  2017 math
drwxr-xr-x   11 ubuntu  admin    352 10 Jul  2017 style

I’m not familiar enough with ansible to make the ansible role work without a tutorial of some kind. I did try, and that’s when I submitted that bug to git yesterday.

I installed prince by installing aptitude and then using the gdebi commands. It’s interesting that the PDF outputs worked from the command line but not from Pressbooks.

Now when I run the same command I get:

$ usr/bin/prince --version
Prince 20171214
Copyright 2002-2017 YesLogic Pty. Ltd.
Non-commercial License

In desperation I have opened the permissions wide open here, trying to see if that was the problem. I know this is not responsible management.

$ ls -al
total 48
drwxrwxrwx 12 www-data www-data 4096 Mar 21 18:41 .
drwxr-xr-x 78 root root 4096 Mar 21 18:41 …
drwxrwxrwx 2 www-data www-data 4096 Mar 21 18:41 bin
drwxrwxrwx 2 www-data www-data 4096 Mar 21 18:41 dict
drwxrwxrwx 12 www-data www-data 4096 Mar 21 18:41 dtd
drwxrwxrwx 2 www-data www-data 4096 Mar 21 18:41 etc
drwxrwxrwx 2 www-data www-data 4096 Mar 21 18:41 hyph
drwxrwxrwx 2 www-data www-data 4096 Mar 21 18:41 icc
drwxrwxrwx 2 www-data www-data 4096 Mar 21 18:41 lib
drwxrwxrwx 2 www-data www-data 4096 Mar 22 15:30 license
drwxrwxrwx 2 www-data www-data 4096 Mar 21 18:41 math
drwxrwxrwx 2 www-data www-data 4096 Mar 21 18:41 style

@beckej Those permissions should be restored to the way they were before. Did you do anything prior to running the --version command again? The first message indicated that Prince could not find the license, the second indicated that it could, so I assume you copied the file there?

The reason for this is that we check to see if a specific version of Prince is installed (11.x or greater) because we need that version for specific Prince features. The /usr/bin/prince --version command was not returning the version so we couldn’t detect the installation properly.

yes I did put the license there. I will restore the owner of those files, and redo the permissions exactly like your screenshot. At this point Pressbooks is still not detecting that the program is installed and report back.

I really appreciate your help.

Corrected settings, Pressbooks still not detecting… What next?

ls -al
total 48
drwxr-xr-x 12 ubuntu admin 4096 Mar 21 18:41 .
drwxr-xr-x 78 root root 4096 Mar 21 18:41 …
drwxr-xr-x 2 ubuntu admin 4096 Mar 21 18:41 bin
drwxr-xr-x 2 ubuntu admin 4096 Mar 21 18:41 dict
drwxr-xr-x 12 ubuntu admin 4096 Mar 21 18:41 dtd
drwxr-xr-x 2 ubuntu admin 4096 Mar 21 18:41 etc
drwxr-xr-x 2 ubuntu admin 4096 Mar 21 18:41 hyph
drwxr-xr-x 2 ubuntu admin 4096 Mar 21 18:41 icc
drwxr-xr-x 2 ubuntu admin 4096 Mar 21 18:41 lib
drwxr-xr-x 2 ubuntu admin 4096 Mar 22 15:30 license
drwxr-xr-x 2 ubuntu admin 4096 Mar 21 18:41 math
drwxr-xr-x 2 ubuntu admin 4096 Mar 21 18:41 style

Are you seeing that Prince is not installed on the Diagnostics page?

exec config:

  • When safe mode is enabled, you can only execute files within the safe_mode_exec_dir.
  • For practical reasons, it is currently not allowed to have … components in the path to the executable.

In a text editor, open this file and navigate to this function:

Change to:

function check_prince_install() {
	if ( ! defined( 'PB_PRINCE_COMMAND' ) ) { // @see wp-config.php
		define( 'PB_PRINCE_COMMAND', '/usr/bin/prince' );
	}

	$output = [];
	$return_val = 0;
	exec( PB_PRINCE_COMMAND . ' --version 2>&1', $output, $return_val );


	print_r( $output ); // TODO: Remove this line after the tech support is done

	$output = $output[0];
	if ( false !== strpos( $output, 'Prince' ) ) { // Command found.
		$output = explode( 'Prince ', $output );
		$version = $output[1];
		print_r( "COMMAND WAS FOUND AND WE THINK IT IS VERSION $version \n\n" ); // TODO: Remove this line after the tech support is done
		if ( version_compare( $version, '11' ) >= 0 ) {
			return true;
		}
	}

	return false;
}

Go to the diagnostics page. At the top you will see something like:

If you don’t see the same thing please see reasons at start of reply?

Can you please install xmllint? Required to test XHTML outputs used by prince.

1 Like

Victory!

So my path to xmllint was wrong, because I had java in there like EPUBCHECK.

So the real problem was never with prince, it was with xmllint.

I wasn’t aware from the documentation that it was a dependency, especially since I had been able to get DocRaptor working previously, and I figured that DocRaptor and Prince would have the same requirements when it came to source information.

Thank everyone so much. I know lots of communities that wouldn’t have taken the time to walk me through this.

2 Likes

Glad we could help out!

Can you please tell me how you installed xmllint ?

Thanks

Did you try something like:

Sudo apt-get install libxml2-utils

Then you would have to determine the exact path to xmllint and get that into your config file.

Yes - I did and it worked. Thanks anyway.