shivaprsd / doq Goto Github PK
View Code? Open in Web Editor NEWThe missing reader mode/color schemes tool for PDFs. π
Home Page: https://shivaprsd.github.io/doq/
License: MIT License
The missing reader mode/color schemes tool for PDFs. π
Home Page: https://shivaprsd.github.io/doq/
License: MIT License
The text looks garbled, but it is actually random letters missing. They are still present in the textLayer
, so I strongly suspect they are somehow being rendered in the background color instead of the foreground.
Difficult to debug since I can't reliably reproduce the issue. It sometimes seem to happen after a quick window resize. This could be possibly related to the canvasData
object not getting cleared and churning outdated data (as happened in #2).
An NPM package would be useful to devs wishing to integrate doq in their projects.
I am not familiar with the Node.js platform, so help in this direction is most welcome.
Does not work properly at all zoom levels.
It is likely related to createMask()
since it happens only for dark backgrounds.
Would be a nice feature to have. Safari reader view already has it.
Need to decide whether this should apply to only the color scheme and tone, or all prefs. Also need to monitor for change in the mode by the user and update the reader accordingly.
When Reader mode is on, printing the document halts abruptly and immediately, without giving any error message.
Upon printing, PDF.js redraws the pages on a bigger offscreen canvas. Since saveCanvas()
does not save imageData
of unattached canvases, the old canvas data is used by getCanvasColor()
, causing an invalid argument to be passed to the Color
constructor.
Currently they are left unhandled, because I have not figured out exactly how to handle them.
Can have any number of color stops, some of which can be closely spaced. It is not clear how all of them should map to the given color scheme.
Note that the CanvasGradient
object is opaque when it reaches getReaderStyle()
. The colors are available only in its addColorStop()
method. So it needs a different treatment altogether.
Is an image, hence should be governed by the image-mode settings. This means we need to modify the composite operation during a fill/stroke operation. Current wrapping paradigm allows modifying only one property at a time; this would need to be changed.
I am also not sure whether they are common enough in PDFs to warrant the added complexity. I plan to evaluate the requirement as I go along reading PDFs with doq.
Suddenly the doq
stopped working for me in Firefox. However, it still worked on Chromium.
After some debugging, I've found that the cause was a previously stored setting scheme
that not matched the colorSchemes
anymore.
I've compared the following pages:
doqment
extension installed.viewer.html
Uncaught (in promise) TypeError: scheme is undefined
updateColorScheme https://shivaprsd.github.io/doq-demo/addon/doq.js:283
updateReaderState https://shivaprsd.github.io/doq-demo/addon/doq.js:277
load https://shivaprsd.github.io/doq-demo/addon/doq.js:83
doqInit https://shivaprsd.github.io/doq-demo/addon/doq.js:16
doq.js:283:9
PDF 110dd61fd57444010b1ab5ff38782f0f [1.4 pdfeTeX-1.21a / TeX] (PDF.js: 2.13.216) app.js:1530:12
updateColorScheme(index) { // index == 3
const scheme = this.colorSchemes[index]; // this.colorSchemes == [{"Safari"}, {"Solarized"}] == 2 items
if (!scheme.tones || !scheme.tones.length) // scheme === undefined --> Exception above
return;
...
},
I've got these value inspecting variables inside the DevTools.
{
flags: {
ββimagesOn: true,
ββshapesOn: true
},
ββscheme: 3, // <- does'nt matches this.colorSchemes
βtone: "2",
theme: "dark"
}
{"scheme":3,"tone":"2","flags":{"shapesOn":true,"imagesOn":true}}
Array [ {β¦}, {β¦} ]
0: Object { name: "Safari", tones: (4) [β¦], colors: [] }
colors: Array []
name: "Safari"
tones: Array(4) [ {β¦}, {β¦}, {β¦}, β¦ ]
ββ0: Object { name: "White", background: "#FFFFFF", foreground: "#1B1B1B", β¦ }
βββ1: Object { name: "Sepia", background: "#F8F1E3", foreground: "#4F321C", β¦ }
βββ2: Object { name: "Gray", background: "#4A4A4D", foreground: "#D7D7D8", β¦ }
βββ3: Object { name: "Night", background: "#121212", foreground: "#B0B0B0", β¦ }
βββlength: 4
βββ1: Object { name: "Solarized", tones: (2) [β¦], accents: (8) [β¦], β¦ }
accents: Array(8) [ "#B58900", "#CB4B16", "#DC322F", β¦ ]
colors: Array(8) [ {β¦}, {β¦}, {β¦}, β¦ ]
name: "Solarized"
tones: Array [ {β¦}, {β¦} ]
βββ0: Object { name: "Light", background: "#FDF6E3", foreground: "#657B83", β¦ }
βββ1: Object { name: "Dark", background: "#002B36", foreground: "#839496", β¦ }
βββlength: 2
βββlength: 2
This makes the code more reliable on bad/corrupted settings:
updateColorScheme(index) {
const scheme = this.colorSchemes[index];
-- if (!scheme.tones || !scheme.tones.length)
++ if (!scheme || !scheme.tones || !scheme.tones.length)
return;
...
},
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.