I attached the source script.
What I meanwhile found, that if to put 3 times "\n" after each line in
the Toc, the TOC is split between the pages(method makeHeader() the
line toc = header_level_markup + spaces + "[[${toc}
${ucMarkup}${parentDoc.getTitle()}>>#H${toc}${ucMarkup}${cleanedTitle}-1
]]" + header_level_markup + "\n\n\n").
Thanks!
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Sergiu Dumitriu
Sent: Monday, July 30, 2012 8:00 PM
To: XWiki Developers
Subject: Re: [xwiki-devs] export to pdf: the content is not carried on
the next page
On 07/30/2012 05:29 AM, Elena Roman wrote:
> Hi,
>
> I am developing a script on groovy which compiles a table of content
> "manually" and then includes the children documents before exporting
> to PDF.
>
> So finally compiled document content looks like
>
> "
>
> =={{{ }}}[[1. Software Requirements
> Specification>>#H1.SoftwareRequirementsSpecification-1]]==
>
> ==={{{ }}}[[1.1. Use cases>>#H1.1.Usecases-1]]===
>
> ===={{{ }}}[[1.1.1. Bite registration and occlusal clearance
> UC
>
> ......
>
>
>
> ......
>
> == 1. Software Requirements Specification==
>
> {{include document="Polaris.SoftwareRequirementsSpecification"
> context="new"/}}
>
> === 1.1. Use cases===
>
> {{include document="Polaris.Use cases" context="new"/}}
>
> ......
>
> "
>
>
>
> But when I export the document to PDf my compiled TOC(which is rather
> large) is not carried on the next page, it is just cut in the middle.
>
> The Export to RTF passes ok with carrying the TOC on the next page.
>
>
>
> Could somebody help to understand where is the problem?
>
It might be a styling problem, meaning that the ToC is forced to be
displayed in just one unbreakable block. It would help if you provide
the intermediary FO file for debugging.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs
{{groovy}}
def String addChildrenToContent(String parentDocName, String content, int level
= 1)
{
parentDoc = xwiki.getDocument(parentDocName)
extendedContent = content;
toc = ""
toc_counter[level - 1] = level == 1 ? 1 : toc_counter[level - 1] + 1
for (byte i = level; i<6; ++i)
toc_counter[i] = 0
header_level_markup = "="
for (byte i=0; i<level; ++i)
{
toc += String.valueOf(toc_counter[i]) + "."
header_level_markup += "="
}
toc += " "
ucMarkup = parentDoc.getObject("MDCode.UseCaseClass") == null ? "" : "UC: "
extendedContent += "\n\n${header_level_markup}
${toc}${ucMarkup}${parentDoc.getTitle()}${header_level_markup}\n\n"
extendedContent += "{{include document=\"${parentDocName}\"
context=\"new\"/}}\n"
for (childName in parentDoc.getChildren())
{
childDoc = xwiki.getDocument(childName)
if (childDoc.getObject("MDCode.IncrementClass") == null)
extendedContent += addChildrenToContent(childName, content, level+1)
}
return extendedContent;
}
toc_counter = [0,0,0,0,0,0]
def String makeHeader(int level = 1)
{
toc_counter[level - 1] = level == 1 ? 1 : toc_counter[level - 1] + 1
for (byte i = level; i<6; ++i)
toc_counter[i] = 0
toc = ""
spaces = "{{{ "
header_level_markup = "="
for (byte i=0; i<level; ++i)
{
toc += String.valueOf(toc_counter[i]) + "."
spaces += " "
header_level_markup += "="
}
spaces += "}}}"
ucMarkup = parentDoc.getObject("MDCode.UseCaseClass") == null ? "" : "UC:"
cleanedTitle = util.clearName(parentDoc.getTitle())
toc = header_level_markup + spaces + "[[${toc}
${ucMarkup}${parentDoc.getTitle()}>>#H${toc}${ucMarkup}${cleanedTitle}-1]]" +
header_level_markup + "\n"
return toc
}
def String makeTOC(String parentDocName, int level = 1)
{
parentDoc = xwiki.getDocument(parentDocName)
toc = " "
toc = makeHeader(level)
for (childName in parentDoc.getChildren())
{
childDoc = xwiki.getDocument(childName)
if (childDoc.getObject("MDCode.IncrementClass") == null)
toc += makeTOC(childName,level+1)
}
return toc;
}
if (request.baselineName != null)
{
targetDocName = "BaselineHelperPage"
if (xwiki.hasAccessLevel("edit", xcontext.getUser(), targetDocName))
{
newDoc = xwiki.getDocument(targetDocName)
newDoc.setTitle(request.baselineName)
newDoc.setParent(doc.fullName)
srsParentDoc = xwiki.getDocument("Polaris.SoftwareRequirementsSpecification")
baselineContent = ""
baselineContent = makeTOC(srsParentDoc.getFullName()) +
addChildrenToContent(srsParentDoc.getFullName(),
baselineContent)
newDoc.setContent("")
newDoc.setContent(baselineContent)
newDoc.save("${request.baselineName}", true)
response.sendRedirect(newDoc.getURL("view", "xpage=pdfoptions"))
}
else
println "{{warning}}You don't have permission to create that
document{{/warning}}"
}
{{/groovy}}
{{html}}
<form action="" id="newdoc" method="post">
<div>
<input type="text" name="baselineName" value="Enter name for new
Baseline" class="withTip"
size="50"/>
<span class="buttonwrapper"><input type="submit" value="Create
Baseline" class="button"/></span>
</div>
</form>
{{/html}}_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs