I've successfully used both user macros and CSS to force page-breaks at various points of the confluence page - when exported to PDF.
I'm not seeing any bookmarks generated, however, following each 'page-break' ?
Why is this so difficult...
Please see my image attachments..
Thanks
OK... This seems to be - the only way to do it...
1) Confluence does not directly support - inserting markup - into the page <head>
This is most unfortunate...
2) However, it is possible to insert <script> which in theory could lookup the head element and insert the bookmark tags when the page is loaded.
Printing the PDF then - should have the bookmarks automatically generated...
This should work...
I got the idea from here:
|
If you must load a script tag into head, you can use the following:
<script>
var script = document.createElement("script");
script.src="path/to/file.js";
document.childNodes[0].childNodes[0].appendChild( script );
</script>
I have found that to be reliable during testing in various browsers,
this assumes that the first nodes in the DOM are <html> and <head> ... a
more resilient option might utilise a function like:
<script>
document.getElementByNodeName = function (name, recurse, parent) {
if (typeof(recurse) == "undefined" || recurse == null) recurse = -1;
if (typeof(parent) == "undefined" || parent == null) parent =
document;
for (var i=0; i<parent.childNodes.length; i++) {
if (parent.childNodes[i].nodeName == name.toUpperCase()) return
parent.childNodes[i];
if (recurse != 0) {
document.getElementByNodeName(name, (recurse-1),
parent.childNodes[i]);
}
}
return null;
}
var script = document.createElement("script");
script.src="path/to/file.js";
script.loading = false;
var head = document.getElementByNodeName("HEAD", 3);
if (head != null) {
script.loading = true;
head.appendChild( script );
}
</script>
Please note - I've not tested that code so it may well have a few bugs
...
Dan Hardiker
Was there any progress on this issue in the last 5 years , anybody successfully implemented a solution for this ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I had similiar questions and what I learned is that "flying saucer" is the library used by confluence. Hence what happens or does not happen when you export to PDF lies within flying saucer.
On their page there is some explanation about how to create PDF bookmarks:
http://code.google.com/p/flying-saucer/wiki/HowTo_PDF_bookmarks_from_xhtml_markup
If there is a simpler method with page breaks I would be happy to know it but I rather doubt it.
But let us know if you found something.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahhh... I'm silly...
I knew flying saucer was the backing library - doing the work - and have come across the project before. That's where I should have been directing my energies !
Thanks for the kick...
I'll look into it - and get back to you...
Cheers
F
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Found something else:
If CSS bookmarks did work it should probably do so as described here. I quickly tried, couldn't get it to work and suppose it doesn't because it is CSS3 and not 2.1.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Steffen
I'm back on this issue... and would like to solve today.
I've researched the google-code FlyingSaucer docs - and have a solution.
See here:
http://code.google.com/p/flying-saucer/wiki/HowTo_PDF_bookmarks_from_xhtml_markup
It will only work - if you're programatically generating your confluence pages... AND inserting the custom bookmark "markup" into the <head> of the confluence page....
I won't be writing any user macros for this...
The question now remains - is there a way to insert content into the <head></head> sections of pages that confluence generates ?
Does confluence provide some custom HTMLMacro ? or UserMacro ? that allows insertion of custom markup - into the html <head> of a page ?
I suspect the technique - defined at the above link - will work..... but I'm having trouble finding mechanisms that would allow me to control where in a page - my markup is placed ?
<head> <body> <script> etc. ?
Hope you may have some ideas ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Steffen....
I mis-spoke.... this will work - without dynamic/programatically generating pages as well...
Nothing is stopping you from taking the code - from referenced website:
<head>
<bookmarks>
<bookmarkname="A bookmark"href="#bm"/>
<bookmarkname="A bookmark 2"href="#bm2">
<bookmarkname="A bookmark 3"href="#bm3"/>
</bookmark>
<bookmarkname="A bookmark invalid"href="#bm99"/>
</bookmarks>
</head>
And just statically.... a) Click page EDIT b) insert markup.... when page is printed - bookmarks will be generated and work as long as referenced href #bm, #bm2 etc. anchors exist...
<body>
<aname="bm1">Jumpmark 1</a>
<aname="bm2">Jumpmark 2</a>
<aname="bm3">Jumpmark 3</a>
</body>
Do you know - is it possible in confluence - with some macro perhaps - to add content to the <head> of a document - not unlike the SytleMacros - that allow you to inject custom CSS styles into a page.... Could we do same with the above <bookmark> code ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I had similiar questions and what I learned is that "flying saucer" is the library used by confluence. Hence what happens or does not happen when you export to PDF lies within flying saucer.
On their page there is some explanation about how to create PDF bookmarks:
http://code.google.com/p/flying-saucer/wiki/HowTo_PDF_bookmarks_from_xhtml_markup
If there is a simpler method with page breaks I would be happy to know it but I rather doubt it.
But let us know if you found something.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi fmisa,
I am afraid I don't have an answer but yet another question:
I would also like to be able to generate bookmarks in the left panel of my PDf file and I don't have a clue how this is done. Do I understand you correctly that you assume that page breaks on the confluence page should create bookmarks on the PDF?
If so, is this documented somewhere or where did you get that information from?
Steffen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Steffen...
Yes - this is my understanding - though given it's not working - maybe I'm wrong ;)
I base my thoughts on these links:
https://answers.atlassian.com/questions/30169/confluence-export-to-pdf-generate-bookmark-index
https://answers.atlassian.com/questions/4625/pdf-export-creates-bookmarks-at-end-of-prior-section
See my previous question:
Check back next week - if I figure this out - I will post my answer here...
Cheers
F
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.