0

I have a requirement to generate OMR marks (can be 10 small lines like '-------') on PDF file where this PDF file template will be prepared using XSLT. The challenging is here for me is, based on the page numbers some OMR lines need to be hidden. For ex: If pdf file page number is 1 then I have to hide 3rd OMR line, if it is second page then have to hide some other OMR line and etc...

I think if we can store the value of 'fo:pagenumber' in one variable then we can write if condition to avoid non required lines. But I'm unable to store 'fo:pagenumber' in variable.

Can any one please suggest how can we achieve it using XSLT FO?

potame
  • 7,597
  • 4
  • 26
  • 33
  • What is *OMR*? (Optical Mark Recognition?) Can you also provide us with the **full** logic of what you would like to achieve? – potame Dec 02 '15 at 08:53
  • Yes, OMR means Optical Mark Recognition. These OMR marks need to be recognized by one of the printer which is intelligent to scan the OMR and can understand the line number. Logic is, we have 10 horizontal lines (OMR marks) one under one and each line has its own description. For ex, in the PDF if it is page no 1 then we have to exclude 3rd line and need keep space in that place. So printer can understand that it is starting page. Like that for every page to recognized by the printer we are going to exclude/hide some lines. Thanks in advance. – Santhosh kumar Tumula Dec 02 '15 at 10:35
  • As potame said, we can recommend an approach only if we know the logic that controls where the OMR marks are placed. Do you need a different mark on every page? Or is there one mark for Chapter 1, another mark for Chapter 2, etc? – Hobbes Dec 03 '15 at 10:09
  • Hobbes, I need different mark on every page. And I don't know the number of pages. – Santhosh kumar Tumula Dec 10 '15 at 06:27

2 Answers2

3

OMR Marking normally consists of two or three different categories of marks. First consider that most OMR marking would need to be applied to a large package of documents like a single long PDF of 1000s of pages consisting of 100s of statements that could vary in page size.

There are marks based on page position in a single document in the package (like first page, last page), there are special marks based possible on something in the data (like the account balance is below $0 so it is printed on a red page) and lastly there are sequence marks which basically is a count 0 to 7, 0 to 7, 0 to 7 for the whole package independent of what statement it is processing. These last marks are used by high speed printers/sorters to validate things are happening as they should (ensuring all pages are being processed).

The easiest way to process this in XSL is to draw the first two types of marks in the document based on the respective rules. These are easy enough to do in the page template masters as they are either positional (first/last) or based on some XPATH data expression like "accountval < 0".

What we do in our solutions is to place a mark at all the other positions -- i.e. put down every 0 to 7 mark. Most all FO processers support processing the fo file to an intermediate representation which can be obtained from the engine serialized into an XML tree structure. This structure includes <page> elements. It is here then you can do the work for the reminder of the marks.

Then it is simply a matter of going through the entire package and "removing" the structures in the logic for each page to make the sequence marks work.

This is the only way you can process a package of documents properly as the sequence marks will naturally cross individual statements in a package -- you may have a 2 page statement, followed by a 10 page statement, followed by a three page statement and you cannot guess at the processing of each where it starts/ends.

If you want to examine one implementation, you could download RenderX's VDPMill application. After install you will find a directory in the installation called "samples" with one of those samples named "OMR". It contains some sample XML and XSL showing an implementation for OMR for Pitney Bowes 8 Series and ABC Office 630 Series machines.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Kevin Brown
  • 8,805
  • 2
  • 20
  • 38
  • Thank you kevin. Your solution is very nearer to my requirement. As you suggested I was trying to download VDPMill application but I could not find it. Will trail version of this software be available? If so could you please send me the link? Thanks a lot. – Santhosh kumar Tumula Dec 10 '15 at 07:29
  • Download trial software form is at http://www.renderx.com/tools/vdpmill.html lower left corner. It sends you key and instructions to download via email. Once installed, what you are looking for is inside the install directory under RenderX\VDPMill\samples\OMR – Kevin Brown Dec 11 '15 at 23:57
0

For a use such as envelope-stuffing, where there is a limited number of pages, you could generate them in the fo:region-start (http://www.w3.org/TR/xsl11/#fo_region-start) and/or fo:region-end regions of the page.

This would require generating two separate fo:simple-page-master for each of page 1, page 2, etc., each with a fo:region-start with a unique region-name value. You'll need two because any page could be the last in the sequence and would need a different OMR code indicating this.

You'd also want an fo:page-sequence-master (http://www.w3.org/TR/xsl11/#fo_page-sequence-master) with as many fo:repeatable-page-master-alternatives as your maximum number of pages. Every fo:repeatable-page-master-alternatives has maximum-repeats="1" and contains two fo:conditional-page-master-reference -- one for when the page is the last page and one for when it isn't, e.g.:

<fo:repeatable-page-master-alternatives maximum-repeats="1">
  <fo:conditional-page-master-reference master-reference="page1-last"
    page-position="last" />
  <fo:conditional-page-master-reference master-reference="page1" />
</fo:repeatable-page-master-alternatives>
...

Your fo:page-sequence/@master-reference would refer to the master-name of the fo:page-sequence-master.

Lastly, you'd have to generate fo:static-content with the right OMR marks for each of the uniquely named fo:region-start in the fo:simple-page-master.

Unfortunately, if you are using OMR marks to indicate the sequence of pages and either you need to indicate the OMR sequence in reverse order to the page numbers or you have to continue the OMR sequence across fo:page-sequence, then this method won't help you.

Tony Graham
  • 7,306
  • 13
  • 20
  • Thank you very much Tony, Will it work if we don't know the number of pages? As you said we have to take one fo:simple-page-master per 1 page. If we don't know the number of pages then how can we write that many of fo:simple-page-master? – Santhosh kumar Tumula Dec 03 '15 at 09:16
  • How many pages are you talking about? I had assumed your OMR was for use with inserting pages into envelopes and that you had a limited number of pages. I just reread about OMR in a manual for an envelope-stuffer (http://support.pb.com/resources82/sites/PBKB/content/live/REF2/14000/RE14672/en_US/SV61656A.pdf) and I see that I had forgotten to account for indicating the last page in the sequence. I'll edit my answer. – Tony Graham Dec 03 '15 at 10:09
  • Thank you Tony. Is there any possibility to increase the value of any global variable across these number fo:repeatable-page-master-alternatives? So that I can find out the page number of last page. – Santhosh kumar Tumula Dec 11 '15 at 14:08