I am using XSLT and XSL-FO for document creation.
I need to introduce multiple sequences of page numbering, i.e main section numbered from 1 to end page, which is broken by two subsequences of corresponding subdocuments, numbered from 1 to end of each of these sections, and after them the main sequence is continued.
The problem I can't overcome is that the subsequences are counted in main sequence, and page number of main section after continuation is incremented page number of previous subsequence.
So I get e.g.
main section
subsection
subsection
continuation of main
1, 2, 3
1, 2
1, 2
3, 4, 5...
And I want
main section
subsection
subsection
continuation of main
1, 2, 3
1, 2
1, 2
4, 5, 6...
How can I achieve it?
In an FO file, the fo:page-sequence elements define a flat list of contents to be paginated, so there is no concept of a "main section" containing "subsections".
The initial-page-number property controls how page numbers are computed for a page sequence.
In particular, when a page sequence ends and a new one starts the only available options concerning page numbering are:
continue the enumeration with the next page number (optionally, the next odd one or even one)
restart from a specified number
There is no way to refer to a different page sequence and say "continue from that".
That said, if your document is not much more complicated than your example you can achieve what you want with a workaround.
This is probably the easiest (and dirtiest) one:
create the pdf output without changing anything; note down the page number that the "continuation of main" section should start from (4, in your example)
modifiy the FO file (or the XSLT), inserting initial-page-number="4" in the appropriate fo:page-sequence
recreate the output file
Slightly more complicated:
modify your XSLT so that it produces the fo:page-sequence elements in the order: (main section) - (continuation of main) - (subsection) - (subsection)
there is no need to specify initial-page-number for the "continuation of main" section; for subsections, use initial-page-number="1" to restart the page numbers (but they are already like this, from your example)
once you have the pdf, use some tool to move the pages around and have them in the order you desire
A cleaner and fully-automated solution would require using FOP's intermediate format:
create the intermediate format output
modify it to fix the page numbers as needed
create the final output from the modified intermediate file
A final note: you did not specify why your document needs such a peculiar page numbering and what degree of control you have on this requirement, but I cannot help wondering whether it is confusing for a reader to see page numbers restart that way, and difficult for them to find what they need ("I am told the information I need is on page 2; but which page 2?").
Related
I'm very new to robot framework. This question is about creating a list variable using Xpath.
I'm trying to write a FOR LOOP in robot in order to print all items that appear on a search result page. Here is what I've done so far:
I tried to declare a list variable using Xpath:
#{product} //div[contains(#class,'ProductCard__TitleMaxLines')]
This Xpath has the number of repetitions the same as the number of items on the page, e.g. 20, so I assume that this list will contain 20 members. --> Is this how it works?
I created a For loop:
${index} Set variable 1
For ${product} in #{related_product}
Exit for loop if ${index} > 20
Log to console ${product}
${index} Evaluate ${index}+1
End
For this, I assume that it will take the first product found on the Xpath to be index=1, and the next index=2, and so on.
That's all I've done so far. Please advise if this works correctly or if there is another way that is better and more typical.
I think your question is, you have similar kind of xpath around 20 times in the webpage. If my understanding is correct, you should use the Get Webelements keyword from Selenium Library.
#{product} Get Webelements //div[contains(#class,'ProductCard__TitleMaxLines')]
The above line will create the list of webelements which having the same xpath
Using XSL-FO I want to create a PDF with two different page-numbers on each page. One number will have an offset based on the sum of all pages of previously generated documents, whereas the other number will represent the page number of the current document, without any offset.
For example:
Document 1 has 3 pages numbered as follows, display on different pages separated by comma:
Header (total numbers): 1, 2, 3
Footer (local numbers): 1/3, 2/3, 3/3
Document 2 has 4 pages numbered as follows, display on different pages separated by comma:
Header (total numbers): 4, 5, 6, 7
Footer (local numbers): 1/4, 2/4, 3/4, 4/4
I know that I can set the initial page number in order to show the total pages in the footer, but than I cannot access the local numbers anymore.
I first tried to modify the value of <fo:page-number />, for example by setting a variable with the page-number, but as How to manipulate page number in FOP? pointed out, this is not working.
In How to manipulate page number in FOP? also is pointed out that the problem might be solved with reprocessing the intermediate format, but this seems kind of complex to solve this seemingly simple problem. Is there any way to achieve the desired result in a single processing-step?
To generate the PDF I use Apache FOP.
Thanks, Felix
I have an XSLFO document with a couple of block elements that have page-break-inside="avoid". Also there is a title-Element before each block-element with keep-with-next.within-page="always".
So basically I have paragraphs with a title and title and paragraph should always be on the same page and there shouldn't be a page-break inside the paragraphs.
The problem is that there are some blocks that have too much content for one page. If the content only overflows the region-body but not the entire page, no page-break occurs, so the block is still on one page.
However, there are blocks where the text overflows the entire page and in that case, there is a page-break-before. One such block element with too much content should be on the first page of the document. However, there is a page-break and it is on the second page of the document.
So in essence, my problem is that there should be no page-breaks within the block-elements (the pargraphs), title and paragraph should always be on the same page AND there should be no page-break before the very first block-element, even if it overflows the entire page. The content should always start on the first page and there should be no empty pages at all.
Thanks for your help and suggestions!
The spec says:
Keep conditions are imposed by the "within-page", "within-column", and "within-line" components of the "keep-with-previous", "keep-with-next", and "keep-together" properties. The refined value of each component specifies the strength of the keep condition imposed, with higher numbers being stronger than lower numbers and the value always being stronger than all numeric values.
Have you tried different values? Maybe you could change page-break-inside="avoid" into keep-together="<your value here>" to use tuned values.
Edit: See spec http://www.w3.org/TR/2006/REC-xsl11-20061205/#keepbreak
I have an XSLT file having multiple simple-page-master. The multiple simple-page-master is used for setting different height and width.
Here I am facing an issue that the pagenumbers corresponding to each simple-page-master starts with 1.
I used < fo:page-number/> for dynamically generating Page numbers.
I also want to get the total number of pages since I have to write Page numbers as
Page 1 of 20
I need pagenumbers in a sequence.
How can I solve this?
Mmmh without more samples, it's hard to try an answer...
I gamble one but quite blindly :
You should have some somewhere. Add a pagenumber param in it. And in your add .
You should be able to output the page number via the param. To get the total number of simple-page-master, add another param or use the XPath count(//simple-page-master) (better to count once and use params).
My requirement is to produce, essentially, a page WITHIN a page. The xsl defines a page 1/3 the size of an A4 sheet, but up to 3 of them must print on the sheet. The page is a standard header/body/footer, with a 'Page X of Y' on it and of course it is simple. But if there are 4 of these "pages", only 2 pages should be printed, 3 on the first and 1 on the second. But 4 pages are printed, because the output PDF "tells" the printer that is a complete sheet. So what I want to do is either:
code the fo so it does not page break after it finished a page (something like page-break-after="avoid" but at the page sequence level)
OR
generate a page sequence within a page sequence, the outer one being defined as A4 size, the inner 1/3 of that.
I've tried the 2nd directly in a simple way, i.e.,
<fo:page-sequence master-reference="A4">
<fo:page-sequence master-reference="one-third_A4">
...
</fo:page-sequence>
</fo:page-sequence>
..and the processor definitely does NOT like it.
Are there any instructions I can apply that could do either of these? I looked in places like schemacentral and w3schools.com and cannot find anything.
Not sure if I understood you needs (a drawing would help), but can't you simply put your content into a series of fo:block-container elements with specified height? They would come out stacked vertically.
If you need more complex geometry, check out flow-maps feature of XSL 1.1. Three body regions per page connected sequentially in a <fo:flow-target-list>, and a single fo:flow providing content for them.
Having fo:page-sequence within another fo:page-sequence is not valid according to the spec (what would a page number mean then?), and every fo:page-sequence starts a new physical page by definition.
fo:page-sequence-wrapper won't help you on sub-page level either.