"commonObj" and "opList" hash difference between Node.js and Chromium environments
See original GitHub issueThe goal:
I’m trying to get the same hash of the commonObjs
and opList
objects ( collections ) in both the Chromium and Node.js environment.
These “hashes” I’m trying to get are Sha256 hashes of the JSON stringified commonObjs
and opList
objects.
The issue:
The issue is that I’m getting a different hash of the opList
and commonObjs
objects in the two different environments ( Node.js and the Browser ).
My assumption is that the structure of the objects is different.
I wish that this can be amended by a simple configuration option, but it could be something tied to the environment that can’t be helped.
Configuration:
Web browser: Chromium Version 89.0.4389.114 (Developer Build) built on Debian 10.9, running on Debian 10.9 (64-bit)
OS: Debian 10.9
PDF.js version: 2.7.570
Node.js version: 10.24.1
The gulp configuration used for building the libraries in both environments: gulp minified-legacy
How to reproduce:
Try out the code in this repository: https://github.com/m-majetic/pdfjs-environment-differences
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top GitHub Comments
Thank you; that’s a lot clearer and it also saves me some time (by not having to clone/run your code).
Unfortunately that’s not really a use-case that’s relevant for e.g. the viewer, and as such we can’t/won’t guarantee that it behaves identically when comparing e.g. browsers and Node.js environments. Please note that the PDF.js library is/was written primarily for usage in browsers, with support for Node.js essentially tacked on afterwards (which unfortunately shows), and we thus by default modify some options to prevent bugs specifically in Node.js environments; see https://github.com/mozilla/pdf.js/blob/master/src/display/api_compatibility.js
Most likely, the differing default options in browsers/Node.js should explain what you’re seeing. You can obviously set the options manually, when calling
getDocument
, such that you get the same behaviour in all environments.Thank you !
I will try out different options and see if they make any difference.
I’d consider this issue closed.