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
Related
This has me stumped. Running a basic data input macro taking data from a CSV file. I have tried formatting the numbers as both general and numbers in excel. It seems to affect random fields - for example, on one run it will affect boxes 1, 3, and 7, and on run 2 it will affect boxes 2, 5, and 8.
For example, this is a line of code:
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:Zip CONTENT={{!COL1}}
In half of the boxes, the entry will be formatted as 58123, and the other half $58,123.00.
I believe this may be a bug related to the implementation of the firefox plugin I am using, as I just ran the code on the same form twice in a row. Same data, same page, no reloads or anything. It had the same issue both times, however the boxes it affected were different. Boxes that were formatted correctly the first time were formatted incorrectly the second, and vice versa. It may also be caused by the plugin being thrown off by boxes that format numbers as currency automatically, as the macro will just "paste" the value in the box without triggering the formatting script, so I would get results like this:
cost: 150
cost: $150
cost: 150
when all of them should read $150 and there is a JS currency formatting function applied to the box. The end result being that numbers that should be formatted as currency are not, and numbers that should not be formatted as currency are.
#chivracq
I slowed timing down to one event every 2s and it did not improve the issue. I am using iMacros 8.9.7 on firefox 47. Windows 10. iMacros FF v10 breaks support for several commands that I need, and Chrome has it's own particular issues with the sites I have to use. Unfortunately finance tends to be picky - surprised we got off of IE6, really. The first version of iMacros I purchased was v8 if I remember correctly, and most of the basic ideas/code were written back then and updated as needed. With iMacros being discontinued now I don't see a point in fixing the issues newer versions have - if I can't get this working I suppose I will have to learn a different automation framework.
My apologies for missing the wiki.
A snippet from my CSV would look like this:
12345678,1407 W Random St,Arlington,22205,800000,800000,10/10/2022,10/20/2022
I could snag some of their code from element inspector perhaps?
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?").
I generate quite complex document by online service into xsl-fo and then i render it to PDF using Apache FOP (1.1 version). Inside document are two page sequences, first with A4 portrait master set and 2nd with A4 landscape master set, both repeated many many times.
My problem is, that A4 portrait part of document should be printed (on paper) using both-sided print and A4 landscape part (table apendices) has to be printed using one-side print - but everything is in one big PDF file.
I use in A4 landscape master set for even pages "blank" master reference ( because of "print" empty back side of every page) - this works OK - but numbering pages by < fo:page-number > directive count these blank pages into page count, so printed page numbering of "one-side-printed" parts is like 1,3,5,7,...
Any idea how to solve?
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.