Skip to main content
Participant
January 22, 2025
Question

Needing to invert black & white on PDF from local server, not through the Chrome .pdf extension

  • January 22, 2025
  • 1 reply
  • 521 views

this has some to do with PDF's, and some to do with chrome extensions so i am posting here and will post elsewhere about how to make a chrome extension that will invert the white and black from a .pdf that is pulled from a local server.

 

every single extension ive downloaded so far has not & does not invert the black & white. the only way ive been able to iis to install the adobe extension, open the pdf in chrome and then go to appearance and invert colors there but many of us do not have an adobe subscription so im trying to create a chrome extension that you can toggle on and off that inverts the black & white on a pdf stored locally.

 

can nyone help with this?

1 reply

Participant
March 22, 2025
quote

this has some to do with PDF's, and some to do with chrome extensions so i am posting here and will post elsewhere about how to make a chrome extension that will invert the white and black from a .pdf that is pulled from a local server.

 

every single extension ive downloaded so far has not & does not invert the black & white. the only way ive been able to iis to install the adobe extension, open the pdf in chrome and then go to appearance and invert colors there but many of us do not have an adobe subscription so im trying to create a chrome extension that you can toggle on and off that inverts the black & white on a pdf stored locally.

 

can nyone help with this?


By E-ZPassCT @Marc32648467ooa2

 

Hello,

Creating a Chrome extension to invert black and white in PDFs stored locally is a great idea! Here's a high-level guide to get you started:

Steps to Create the Extension
Set Up the Manifest File:

Create a manifest.json file to define your extension's metadata and permissions. For local PDFs, you'll need the "file://*/*" permission.

Inject a Content Script:

Write a content script in JavaScript that applies a CSS filter to invert colors. For example:

document.body.style.filter = "invert(1)";

Handle Local PDFs:

Use the chrome.fileSystem API to access local files. Ensure your extension has the "fileSystem" permission.

Add a Toggle Button:

Create a browser action (e.g., a button in the toolbar) to enable or disable the inversion. Use chrome.storage to save the toggle state.

Test Your Extension:

Load your extension in Chrome's developer mode and test it with local PDFs.

Challenges and Tips
PDF Rendering: Chrome's built-in PDF viewer might not allow direct manipulation. You may need to use a library like PDF.js to render and manipulate PDFs.

User Permissions: Ensure users enable "Allow access to file URLs" in the extension settings for local files.

 

Hope this helps!

Best regards,
Edna