[javascript] bug in reading order for Report documents

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Mathew
User
Posts: 570
Joined: Thu Jun 19, 2014 7:30 pm

[javascript] bug in reading order for Report documents

Post by Mathew »

When javascript creates a text report pdf, and columns of text are separated with tabs, the reading order of the created pdf prevents selecting the text in a logical way.

For example, the following script makes two columns, the left with the keys, the right with the values.

Code: Select all

// test of reading order for Report
{
    const object1 = {
      a: "some string",
      b: 42,
      c: false,
    };
    
    const rep = new Report();
    
    for (let k in object1) {
        rep.writeText( k + '\t' + object1[k]);
    }
    
    rep.open();
}
PXCE formats the columns nicely, but: Attempting to select the text in the resulting report is bizarre:
image.png
If I copy all the text and paste it, it is all jumbled:

Code: Select all

a 

some string
42
false

b 

c 
The expected result would be that it is selected in the same way it appears:

Code: Select all

a some string
b 42
c false
There is a workaround (use Accessibility > Reading Order to manually select each row) but PXCE is getting the text from js in the correct order, so IMO it should store the correct reading order during document creation.
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11029
Joined: Wed Jan 03, 2018 6:52 pm

Re: [javascript] bug in reading order for Report documents

Post by Daniel - PDF-XChange »

Hello, Mathew

Thank you for the report, I have passed this along to the Dev team for review!

[Edit]
This seems to have been caused by the "Preferences > Page display > Detect tables by Text layout" option, though we are as of yet unsure why. The Dev team is looking into a resolution for this in the future. I am sorry to say this may be a slightly longer term fix.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com