Forum How do I...?

Print URL in footer

nico
Hi,

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 ?
mikeday
Yes, you can use "content: prince-base-url()".
nico
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 "http://home.web.cern.ch/about/updates/2013/10/cern-releases-photos-under-creative-commons-licence" -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)

*/

@page
{
	size: A5;
	margin: 2cm 2cm 3cm;
	@bottom-center
	{

		/* This works. The URL will wrap to the next line. */
		/*content: "http://home.web.cern.ch/about/updates/2013/10/cern-releases-photos-under-creative-commons-licence" "\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;
	}
}
mikeday
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! :)
mikeday
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!
mikeday
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.