Counting only odd pages by <fo:page-number> in XSL-FO - xslt

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?

Related

iMacros formatting random numbers as currency, does not affect the same field each time

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?

How to convert a decimal into it's time equivalent as part of a function?

I'm running into an issue when trying to compare data across two sheets to find discrepancies - specifically when it comes to comparing start and end times.
Right now, the "IF" statement in my screenshot is executing perfectly, except when a time is involved - it's reading those cells as decimals instead (but only sometimes).
I've tried formatting these cells (on the raw data AND on this "Discrepancies" report sheet) so that they are displayed as a "HH:MM am/pm" time, but the sheet is still comparing the decimal values.
Is there anything that I can add to this function to account for a compared value being a time instead of text, and having that text be compared for any discrepancies? I cannot add or change anything to the raw data sheets, the only thing I can edit is the formula seen in the screenshot I provided.
See the highlighted cells in my screenshot - this is the issue I keep running into. As you can see, there are SOME cells (the non-highlighted ones) that are executing as intended, but I'm unsure why this isn't the case for the whole spreadsheet when I've formatted everything the same way using the exact same formula across the whole sheet.
For example, the values in cell N2 is "8:00 AM" on both sheets, so the formula should just display "8:00 AM" in that cell (and NOT be highlighted) since there is no discrepancy in the cells between both sheets it's comparing. But instead, it's showing both times as a decimal with the slightest difference between them and is suggesting a difference where there technically isn't (or shouldn't be) one.
Please help!
Screenshot of original spreadsheet for reference
---EDIT (added the below):
Here is a view-only version of a SAMPLE SHEET that displays the issue I'm having:
https://docs.google.com/spreadsheets/d/1BdSQGsCajB3kOnYxzM3sl-0o3iTvR3ABdHpnzYRXjpA/edit?usp=sharing
On the sample sheet, the only cells that are performing as intended are C2, E2, G2, I2, K2, K6, or any cells that contain text like "Closed". Any of the other cells that have a time in both raw data tabs appears to be pulling the serial numbers for those times instead of correctly formatting it into "HH:mm AM/PM".
A quick tour of how the SAMPLE SHEET is set up:
User enters raw data into the "MicrositeRawData" and "SalesforceRawData" tabs.
Data is pulled from the "SalesforceRawData" tab into the "CleanedUpSalesforceData" tab using a QUERY that matches the UNIQUE ID's from the "MicrositeRawData" sheet, so that it essentially creates a tab that's in the same order and accounts for any extraneous data between the tabs (keep in mind this is a sample sheet and that the original sheet I'm using includes a lot more data which causes a mismatch of rows between the sheets which makes the QUERY necessary).
The "DISCREPANCIES" tab then compares the data between the "MicrositeRawData" and "CleanedUpSalesforceData" tabs. If the data is the same, it simply copies the data from the "MicrositeRawData" cell. But if the data is NOT the same, it lists the values from both sheets and is conditionally formatted to highlight those cells in yellow.
If there is data on the "MicrositeRawData" tab that is NOT included on the "SalesforceRawData" tab, the "DISCREPANCIES" tab will notate that and highlight the "A" cell in pink instead of yellow (as demonstrated in "A5").
try in B2:
=IF(MicrositeRawData!B2=CleanedUpSalesforceData!B2, MicrositeRawData!B2,
"MICROSITE: "&TEXT(MicrositeRawData!B2, "h:mm AM/PM")&CHAR(10)&
"SALESFORCE: "&TEXT(CleanedUpSalesforceData!B2, "h:mm AM/PM"))
update
delete all formulae from range B2:O10 and use this in B2:
=ARRAYFORMULA(IF(TO_TEXT(MicrositeRawData!B2:O10)=
TO_TEXT(CleanedUpSalesforceData!B2:O10), MicrositeRawData!B2:O10,
"MICROSITE: "&TEXT(IF(MicrositeRawData!B2:O10="",
"", MicrositeRawData!B2:O10), "h:mm AM/PM")&CHAR(10)&
"SALESFORCE: "&TEXT(IF(CleanedUpSalesforceData!B2:O10="",
"", CleanedUpSalesforceData!B2:O10), "h:mm AM/PM")))

Multiple page counters in a single document with xsl-fo

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

XSL-FO: Need to disable page break at page sequence level

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.

How to iterate over all the page breaks in an Excel 2003 worksheet via COM

I've been trying to retrieve the locations of all the page breaks on a given Excel 2003 worksheet over COM. Here's an example of the kind of thing I'm trying to do:
Excel::HPageBreaksPtr pHPageBreaks = pSheet->GetHPageBreaks();
long count = pHPageBreaks->Count;
for (long i=0; i < count; ++i)
{
Excel::HPageBreakPtr pHPageBreak = pHPageBreaks->GetItem(i+1);
Excel::RangePtr pLocation = pHPageBreak->GetLocation();
printf("Page break at row %d\n", pLocation->Row);
pLocation.Release();
pHPageBreak.Release();
}
pHPageBreaks.Release();
I expect this to print out the row numbers of each of the horizontal page breaks in pSheet. The problem I'm having is that although count correctly indicates the number of page breaks in the worksheet, I can only ever seem to retrieve the first one. On the second run through the loop, calling pHPageBreaks->GetItem(i) throws an exception, with error number 0x8002000b, "invalid index".
Attempting to use pHPageBreaks->Get_NewEnum() to get an enumerator to iterate over the collection also fails with the same error, immediately on the call to Get_NewEnum().
I've looked around for a solution, and the closest thing I've found so far is http://support.microsoft.com/kb/210663/en-us. I have tried activating various cells beyond the page breaks, including the cells just beyond the range to be printed, as well as the lower-right cell (IV65536), but it didn't help.
If somebody can tell me how to get Excel to return the locations of all of the page breaks in a sheet, that would be awesome!
Thank you.
#Joel: Yes, I have tried displaying the user interface, and then setting ScreenUpdating to true - it produced the same results. Also, I have since tried combinations of setting pSheet->PrintArea to the entire worksheet and/or calling pSheet->ResetAllPageBreaks() before my call to get the HPageBreaks collection, which didn't help either.
#Joel: I've used pSheet->UsedRange to determine the row to scroll past, and Excel does scroll past all the horizontal breaks, but I'm still having the same issue when I try to access the second one. Unfortunately, switching to Excel 2007 did not help either.
Experimenting with Excel 2007 from Visual Basic, I discovered that the page break isn't known unless it has been displayed on the screen at least once.
The best workaround I could find was to page down, from the top of the sheet to the last row containing data. Then you can enumerate all the page breaks.
Here's the VBA code... let me know if you have any problem converting this to COM:
Range("A1").Select
numRows = Range("A1").End(xlDown).Row
While ActiveWindow.ScrollRow < numRows
ActiveWindow.LargeScroll Down:=1
Wend
For Each x In ActiveSheet.HPageBreaks
Debug.Print x.Location.Row
Next
This code made one simplifying assumption:
I used the .End(xlDown) method to figure out how far the data goes... this assumes that you have continuous data from A1 down to the bottom of the sheet. If you don't, you need to use some other method to figure out how far to keep scrolling.
Did you set ScreenUpdating to True, as mentioned in the KB article?
You may want to actually toggle it to True to force a screen repaint. It sounds like the calculation of page breaks is a side-effect of actually rendering the page, rather than something Excel does on demand, so you have to trigger a page rendering on the screen.