Support for RTL pdf reading on tables using JasperReports framework - jasper-reports

I am tring to build an accessible for the hard of seeing pdf file using JasperReports java framework
There is an option of adding accessable tags to tables, but it looks like the reading is done from left to right
This is not what I need, since this is a hebrew (rtl language) pdf
I see that there is support for RTL crosstab elements in JasperReport, but I didn't see any for tables
What would you suggest as the best way to have the accessable rtl support on pdf tables?
Tried to use chat gpt, unfortunately it gave me all kind of properies to use that were not recognized by Jasper
I tried to reorder the tables rows after having jasper calculate there positions, but that caused some of the rows not to be read properly

I solved this by overriding the exportFrame(JRPrintFrame frame) and exportElements(Collection elements) methods in JRPdfExporter of the JasperReports framework
In exportFrame(JRPrintFrame frame) I chacked if we are in table using the "net.sf.jasperreports.export.accessibility.tag" property
if so I marked this
In the exportElements(Collection elements) method I check if we are in a table and if so I swapped the text, x and width values of the left and right elements (for example if we have 4 elements, than I swap element at index 0 with that in index 3 and element at index 1 with the element at index 2
by doing this the order of the tags (witch dictates the read aloud order) is different then the drawing order (witch dictates how it is seen in the pdf)

Related

Merge columns with identical values in a smart table (responsive table)

Is it possible to merge duplicates in a sapui5 smart table?
In a smarttable (with a responsive table) we are grouping values by supplier and would like to merge duplicated values into one cell to get a better readability of the responsive table.
Outside of Fiori elements (smarttable) this can be done in the column definition in XML using mergeDuplicates: true.
Should be possible to merge duplicates via SAP UI5 Visual Editor, the properties of controls are available there.
Not all properties are subject to change. Only properties that have been enabled for editing may be changed.
Best,
Shanir

Itext 7 - Cannot get tab order of the field

Is it possible to get the tab order of the PDF field with iText7?
You can define tab order in Acrobat but getting that tab order doesn't seem to be available in the iText7 library.
I'm writing an application that extracts the fields from the PDF file and wanted those fields to be sorted depending on the tab order defined from the PDF.
The order of fields (or more to the point: of annotations) on a page is determined by the Tabs entry in the page dictionary. Its value is specified as:
(Optional; PDF 1.5) A name specifying the tab order that shall be used for annotations on the page (see 12.5 "Annotations"). The possible values shall be R (row order), C (column order), and S (structure order). Beginning with PDF 2.0, the possible values also include A (annotations array order) and W (widget order). Annotations array order refers to the order of the annotation enumerated in the Annots entry of the Page dictionary (see "Table 31 — Entries in a page object"). Widget order means using the same array ordering but making two passes, the first only picking the widget annotations and the second picking all other annotations.
(ISO 32000-2, Table 31 — Entries in a page object)
To implement your task of extracting fields to be sorted depending on the tab order defined from the PDF, therefore, you have to read this value for the page in question and depending on it, analyze the annotation coordinates, the structure tree, or the annotation array accordingly.
By the way, for fields with multiple widgets this means that they also have multiple tab positions; thus, exporting the fields to be sorted depending on the tab order defined from the PDF may be impossible for some documents.

How to make repeated content control through OpenDoPE add-in

I have table with one row of content controls. I need to repeat the row as per the data xml using OpenDoPE add-in of MS Word
See the below table and xml mapping which I have done.
Currently there is one row node in xml so one row of content-control is enough. But when I add more row nodes in xml the content control is not repeating.
Help me to resolve this
Looks like you are using the "first/oldest" AddIn from https://opendope.org/implementations.html
There is a description of how to use it at http://www.opendope.org/WordAddIn_walkthrough.pdf
But you are probably better off using http://www.opendope.org/downloads/authoring-friendly/setup.exe which uses the drag/drop approach Microsoft introduced in Word 2013.
This answer uses that. (Before installing it, first uninstall the old one, using Windows "Programs and Features").
Using sample XML:
<myxml>
<rows>
<row>
<name>Abh</name>
<company>Standout</company>
<designation>Dev</designation>
</row>
<row>
<name>Name2</name>
<company>Co2</company>
<designation>Design2</designation>
</row>
</rows>
</myxml>
(note the rows element) and name, company and designation already mapped as per your question:
select the table row, then in the XML Mapping task pane, right click on row (ie the first of the siblings to be repeated, not the parent), choose Repeat > Insert Content Control:
In Design Mode, you should now see:
(note the od:repeat around the three table cells)
Save the docx, then you can try using https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/ContentControlBindingExtensionsOld.java (update line 69 to point at your docx).
Any way I found myself a solution to this. The problem was regarding the designing of repeated content control in my template docx. I just created a rich text content control and placed my entire row (which contains the name, company, designation content controls) inside it and mapped as repeated. This resolved my problem. See the below content control design
Here is the xml mapping of name field
here is the xml mapping of repeated content controll (row)

How to split table cells in Open Xml?

I have a document with a table. I need to be able to add columns to a specific row, while maintaining the original table width.
Essentially I need to SPLIT table cells. How can I do this using open xml for a word document?
I tried
var tc = new TableCell();
tc.Append(new Paragraph(new Run(new Text("Hi"))));
row.Append(tc);
I tried just adding more cells, however it acts as new column and increases the size of the table.
First of all create a table in microsoft word and split cell there. Now open your word document in OpenXML SDK Development Tool which can be downloaded from here. If you look at the relevent cell in OpenXML, you will find the answer to your problem. Just copy code from OpenXML and make any necessory changes according to your requirements.

PdfpTable vs. Table (vs. SimpleTable?)

I am writing code that generates both PDF and RTF documents, depending on the user's selection. The information in both documents is the same.
Until now, we were using classes like Table, Cell, HeaderFooter, etc., which are rendered into the correct form by the documentwriter (either PdfWriter or RtfWriter2).
However, the further I get into trying to make changes (mostly because the upgrade to iText 2.1 left the spacing a little quirky), the more I'm being told to "use PdfpTable", or "Use pageEvents to set headers". It seems like a lot of the generic classes are being deprecated.
I am thinking of revamping the code to separate out the table creations for PDF and RTF. However, all the iText tutorial stuff seems to actually recommend using Table in an instance where both PDF and RTF documents are needed.
Additionally, it appears that while there is a PdfpTable class, there is nothing similar for RTF, so I would be using Table anyway, which would leave me vulnerable to all the quirks that come along with the now unsupported Table class.
Basically, what are the benefits/downsides of separating the code into two sections -- one to create PDF documents, and one to create the same documents in an RTF format, if that was selected? And where does SimpleTable come in to all of this? Will it give me the flexibility that I need?
Thanks!
From the book iText In Action, end of chapter 6:
If you look at the iText API, you’ll also find some other table classes. com.lowagie.text.Table is the original table class; it dates from the early iText days. It uses class com.lowagie.text.pdf.PdfTable internally to render a table to PDF (don’t confuse this class with PdfPTable).
There’s also the newer SimpleTable class, which tries to form a link between
PdfPTable and Table. It’s able to translate itself to a PdfPTable if you add it to a
document that writes PDF or to a Table if you’re producing HTML or RTF. [...]
The major disadvantage of the Table class is that it’s no longer supported. Different
people have fixed most of the known issues, but today not a single person
understands if and how all the Table-methods work. If you decide to use this class,
you’re more or less on your own, and you’ll encounter lots of quirky layout issues
based on historical design decisions. However, this doesn’t mean you can’t make
good use of the Table class.
Advantages of the Table class
With the Table class, you can generate a table structure that can be rendered in
PDF, RTF, and HTML. If you compare the results, you’ll see there are small differences
in the way the table is rendered. This is normal; not every table feature is
supported in every document format.
You can generate a table in PDF, HTML, or RTF using the same code.
You can set padding and spacing the way it’s done in HTML.
You can use the row span without having to resort to nested table.
You can change the number of columns even after you’ve added cells.
You can add cells at specific positions (the number of rows is augmented
dynamically).
You can delete a column before adding the table to the document.
You can let iText add the Table as if it was a PdfPTable.
You get a PdfPTable object based on the Table object.
As opposed to PdfPTable, you can add cells to a Table in a random order, and add
or delete columns if needed. You can even translate a Table to a PdfPTable if you
didn’t use setRowspan().
There’s also the SimpleTable, class, which is a simplified version of (PdfP)-Table. When adding a SimpleTable to a PDF document, iText first attempts to add
the table as a PdfPTable; if this fails, it’s added as a Table. When adding a SimpleTable to an RTF or HTML document, it’s added as a Table. SimpleTable differs
from the Table and PdfPTable in the sense that it reintroduces the concept of rows.
This can be handy if you’re parsing an XML file that has a table-row-cell structure.
If the tag corresponding with the rows has attributes, you don’t have to define this
property for each cell in the row separately; you can set the property for the entire
row at once.
Summary
PdfPTable should be your first choice; but depending on the requirements defined for your project, there can be good reasons to opt for Table or SimpleTable.