Forum How do I...?

Transforming existing HTML to PDF solution to Prince

Suku Steff
Hello everyone,

the way we are producing pdf documentation in our company is to first create html files in a wiki system (called Confluence) and then convert them to pdf files with the included html to pdf converter of that wiki system plus a CSS stylesheet made by me.
I would like to keep the first part (the html files and the way they are created) but switch to Prince for the conversion from html to pdf.

Now, I am trying to get an idea how that would work and what I have to consider.

In more detail:
We have numerous html files for different information bits. To put a document together, the html files are included and arranged in a master file. This master file is one big html document.

So, what I have as a starting point is one single html file that includes all the content.

What might be important to know is this:
1. I don't have control about the html source code of that file. It is created by the wiki system. There might be parts that are not valid, there might be other things included like other CSS stylesheets or javascript bits.

2. This master file is built within the frame work of that wiki. The page also includes the header and the navigation of the wiki system, parts that should not appear in the exported PDF.
Here, I am searching for the best way to get rid of that.
* Should I copy the whole html code first and delete the unwanted parts or
* can I track down these parts and use "display: none" in the CSS to get rid of them or
* does Prince include some function that does that for me (I read about "sanitize" which sounded like a possible solution).

3. The whole wiki system and therefore also that master page is password protected. I guess I have to pass the password to Prince to make it work.
I read about "Authentication" (see below), but haven't fully understood it.
What I am hoping to find is a way to add the password to the URL that I enter in the Prince GUI.
Does that work?

"Authentication

If authentication is required for the URL, the credentials can be passed by means of the --auth-user and --auth-password command-line options. A more cautious way is to add the --auth-server option, which sends username and password credentials to the specified server only - the default is to send them to any server which challenges for authentication. The option --auth-scheme sends username and password credentials only for requests with the given scheme, either HTTP or HTTPS, while --auth-method specifies a comma separated list of HTTP authentication methods to enable. Valid entries are: basic, digest, ntlm and negotiate."


As mentioned before, the CSS stylesheet for the conversion is fully finished.

If I were able to
1. take the existing html pages
2. get rid of those parts that I don't want
3. have Prince convert the html pages as defined in my CSS stylesheet
I am already done.

But so far, I was not able to sucessfully run Prince.
At the moment it runs through the page but doesn't create a file and shows an error "TypeError: undefined value is not an object"

mikeday
The error is coming from JavaScript, but Prince should still create a PDF file, are there any other errors?