Forum How do I...?

Print URL in footer


I would like to make a PDF from a web page and print the URL in the footer. Is there a variable that stores the URL ?
Yes, you can use "content: prince-base-url()".
Thank you for your answer.

I’ve tested it and I have a problem with long URL. Can you tell me how to wrap them?

Here is an example :

@charset "utf-8";


Save this css in prince_web.css.

Then run :
prince "" -s prince_web.css -o prince_web.pdf

You can do it twice and change the "content" below (once with url as string and once with url taken from prince-base-url)


	size: A5;
	margin: 2cm 2cm 3cm;

		/* This works. The URL will wrap to the next line. */
		/*content: "" "\A\A" counter( page );*/

		/* This doesn’t work. The URL will NOT wrap to the next line. */
		content: prince-base-url() "\A\A" counter( page ) " / " counter( pages );

		border-top: 1px solid;
		word-wrap: break-word;
		white-space: pre-line;
		vertical-align: center;
		padding: 0.5em 0 1em;
		margin: 0;
It appears that Prince does not apply the prince-linebreak-magic and prince-text-replace properties to the prince-base-url() generated content function. This makes it difficult to wrap long URLs. But it is a minor oversight, and should be easy for us to fix in the next maintenance release of Prince 9. Thanks for letting us know about this issue! :)
We have fixed this minor oversight in Prince 9 rev 4, and now the prince-linebreak-magic and text-replace properties do apply to generated content functions. Thanks again for letting us know!
Prince 10 is now available, and supports the word-wrap property, which can be a more convenient way to ensure that long text breaks instead of overflowing.