# Raycast extension

Scan the tab in front of your browser from Raycast, as a vector PDF, a PNG or a JPEG.

**Scan Current Tab**, a command in Raycast, captures the tab in front of your browser, saves it as a
PDF whose text you can still select and search (or as a PNG or a JPEG) and copies the file. It is in
the Raycast Store as [Page Scanner](https://www.raycast.com/sbd530/page-scanner), for Raycast on
macOS.

The capture is done by the web extension in your browser, as it is for [the command line](https://docs.pagescanner.app/cli):
the Raycast extension carries the `page-scanner` command inside it and runs it, so there is no
Node.js or npm package to install.

## Set it up

1. Install [the web extension](https://docs.pagescanner.app/extension) 1.3.0 or newer, in Chrome, Edge, Brave, Arc or
   Vivaldi.
2. Install [Page Scanner](https://www.raycast.com/sbd530/page-scanner) from the Raycast Store.
3. In Raycast, run **Set Up Page Scanner** and press **Install Helper**.
4. In the extension's settings, under [Local agents](https://docs.pagescanner.app/extension/local-agents), press **Connect** and
   allow what the browser asks.

**Set Up Page Scanner** shows both steps as done or to do and checks again every few seconds. The
helper is the same one `npx @page-scanner/cli install` sets up, so a computer that already has it
skips step 3.

## Scan a tab

Run **Scan Current Tab** from Raycast's search. It scans the active tab of the browser window in
front. With several windows open, it asks that browser which page its front window shows, which
macOS asks you to allow once.

The file goes into **Save To** (Downloads when empty), and **After Scanning** decides what happens
next: copy the file (the default), show it in Finder, open it, or open the capture in the
extension's editor. A scan never replaces an earlier file: a second scan of the same site in the
same minute is saved with `-2` added to its name.

Run the commands from Raycast's search. A `raycast://extensions/sbd530/page-scanner/…` link opened
from elsewhere makes Raycast ask first.

## Preferences

In Raycast's settings, under **Extensions**, **Page Scanner**:

| Preference     | Choices                                                                         |
| -------------- | ------------------------------------------------------------------------------- |
| Save To        | a folder; Downloads when empty                                                  |
| File Name      | a template: `{host}`, `{name}`, `{date}`, `{time}`, `{ext}`; `/` makes a folder |
| Format         | PDF, PNG, JPEG                                                                  |
| Page Size      | A4, US Letter, one long page                                                    |
| Markdown       | none, a `.md` beside the file, or only the `.md`                                |
| Theme          | as in Page Scanner's settings, the browser's, light, dark                       |
| Page Width     | as in Page Scanner's settings, the window's, A4, US Letter                      |
| Hide Clutter   | as in Page Scanner's settings, all of it, none of it                            |
| After Scanning | copy the file, show it in Finder, open it, open the capture in the editor       |
| Browser        | a connected browser's label or ID, when more than one is connected              |

"As in Page Scanner's settings" leaves the choice to the extension's
[Capture settings](https://docs.pagescanner.app/extension/settings#capture). The editor's own output (a crop, marks, a frame, a
stamp, PDF/A, text recognition) is not applied to a scan from Raycast; set **After Scanning** to
open the capture in the editor and add it there.

## When a scan cannot reach the browser

The message says which step is missing: the helper is not set up yet, or the browser has not
pressed Connect. A helper whose Node.js is no longer there is set up again on the
spot, and the scan waits for the browser to reconnect. **Set Up Page Scanner**
shows it as **Needs repair**, with a **Repair Helper** action. A browser installed after the
helper is listed there under **Not in every browser**, with **Install Helper**.

## What it does outside Raycast

It runs the command it carries as a separate process. The command keeps its pairing in
`~/.page-scanner/`, where **Install Helper** also puts the small launcher your browser starts, and
a background process it starts keeps running after the Raycast command ends. Nothing goes over the
network beyond this computer: the command listens on `127.0.0.1` only, and the page is captured by
your own browser.
