Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

font-decoding.js wrong arguments, pass 1 argument which is a valid index in the array #35

Open
blairjanis opened this issue Sep 23, 2022 · 0 comments

Comments

@blairjanis
Copy link

When using the sample for extracting text, I kept getting an error in the font-decoding.js code. The issue is on line 76:

map[j] = besToUnicodes(unicodeArray.queryObject(j).toBytesArray());

queryObject(j) throws an error because j is a number representing the items position in the map that is getting created during the parsing but the unicodeArray is usually just a length of 1 where my pdfs are hitting this code. So using j tries to pull an index in the array that doesn't exist.

I was able to fix the issue by changing things thusly:

if(operands[i+2].getType() === hummus.ePDFObjectArray) {
    var unicodeArray = operands[i+2].toPDFArray();
    // specific codes
    for(var j = startCode;j<=endCode;++j) {
        map[j] = besToUnicodes(unicodeArray.queryObject(j).toBytesArray());
    }
}

becomes ...

if(operands[i+2].getType() === hummus.ePDFObjectArray) {
    var unicodeArray = operands[i+2].toPDFArray();
    // specific codes
    var index = 0;
    for(var j = startCode;j<=endCode;++j) {
        map[j] = besToUnicodes(unicodeArray.queryObject(index).toBytesArray());
        index++;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant