doqment
doqment copied to clipboard
Two questions
hello, thank you for your work.
- After installing the plugin in Firefox, when I try to open a pdf file with 'open with Firefox`, it does not open the pdf file directly. I need drag the file to the browser. Is there any way to directly open a pdf file?
- Do you know how to set set
about:config
in Firefox to get the same effect? When I setpdfjs.forcePageColors
totrue
andpdfjs.pageColorsBackground
to a hex value, it changes both the background and the image color in the pdf. In fact, I want to change the background color only.
Thanks.
@cxw-droid Thanks for stopping by! To answer your questions:
- Do you mean when you right click a PDF file in your OS file manager and choose
Open with Firefox
? Unfortunately, no. I am sorry, but this is a restriction imposed by Firefox on us. As much as I also want this to work, Firefox does not let extensions accessfile:///
URLs (which is what it gets when you do the above action). Here is the relevant function (note how it says 'Firefox will always returnfalse
'). It works when you drag and drop because then the extension gets the file itself in that case. - Again, sorry, I cannot help you here. I am aware of those options in
pdfjs
, but I don't know how they work and why it would modify image colours. You would be better off asking this in the PDF.js repo, they can provide the correct method (if any). Although I am also curious how it changes the image colours. I don't have Firefox at the moment to test, can you upload a screenshot of what you get?
Thank you for your reply.
- Yes, I use
open with Firefox
after right clicking a pdf file. Is it possible after I open a pdf file this way, then click some add-on button (like thedoqment
) to change its background color? Or you are using your ownpdfjs
indoqment
and it is impossible to control thepdfjs
backed pdf viewer from Firefox? - There is another method trying to change the background color like this, but it seems filter does not work well to change the background color only. Is it possible to use other
js
code to achieve this? - The image becomes black and white like this:
@cxw-droid
- Exactly! It is another restriction (😩) imposed by Firefox that extensions cannot modify the built-in
pdfjs
viewer (the reason cited being that the viewer is not a webpage but is a "part of Firefox" 🤷🏼♂️). - This is what doqment does. 🙂 The point is you have to do this while the PDF is rendered, because after render it is just a raster image, i.e. just pixels. The filter technique you linked only inverts the pixels (in fact there is a filter-only option in doqment too, it is the last color swatch in the panel).
- Aha! That is technically not an image, but a vector shape. Probably shapes are drawn with the same colors as the text when
pdfjs.forcePageColors
is on (again in doqment you can control this from the expanded panel). If you open a PDF with an actual photograph the image colors would be rendered as normal I expect.
Closing as answered.