Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ demo/**
.prettierignore
.prettierrc
.yarnrc
.github/**
.vscode-test/**
CODE_OF_CONDUCT.md
CONTRIBUTING.md
generateEmojiShortcodeMap.js
Expand All @@ -30,3 +32,9 @@ tsconfig.webviews.json
tsconfig.tsbuildinfo
webpack.config.js
yarn.lock
node_modules/pdfjs-dist/legacy/**
node_modules/pdfjs-dist/types/**
node_modules/pdfjs-dist/web/**
src/test/**
demo/**
docs/**
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## [0.6.0] - 2025-12-24

### Major Changes

- **Internal Rendering**: Removed dependency on external tools (`Ghostscript`, `Poppler`, `pdfcairo`). The extension now renders PostScript files internally using WebAssembly (`postscript-wasm`) and `pdf.js`.
- **Zero Config**: Removed all path configuration settings. The extension works out of the box without any setup.

## [0.5.4] - 2025-12-23

- Fixed an issue where previewing files with special characters in the filename (e.g., spaces, parentheses) would fail with a syntax error.
Expand Down
65 changes: 3 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
<p align="center">
<img src="https://github.com/ahnafnafee/PostScript-Preview/raw/master/images/logo.png" alt="PostScript Preview Logo" width="128px" height="auto" />
</p>
<p align="center">
<br/>
<a title="READ REQUIREMENTS AFTER INSTALL" href="#-requirements"><img src="https://github.com/ahnafnafee/PostScript-Preview/raw/master/docs/images/req-btn.png" alt="Read Requirements After Install"></a>
</p>

<h1 align="center">PostScript Preview for VS Code</h1>

Expand Down Expand Up @@ -41,69 +37,14 @@
This extension requires:

- **[PostScript Language](https://marketplace.visualstudio.com/items?itemName=mxschmitt.postscript)** extension for syntax highlighting
- **GhostScript** (provides `ps2pdf`)
- **Poppler** (provides `pdftocairo` and `pdfinfo`)

### macOS

```bash
brew install ghostscript poppler
```

### Ubuntu / Debian

```bash
sudo apt-get install ghostscript poppler-utils -y
```

### Windows

Install via [Chocolatey](https://chocolatey.org/install) (run as Administrator):

```powershell
choco install ghostscript --version 9.55.0 --force -y
choco install poppler --version 0.89.0 -y --force
```

Add to PATH:

```powershell
[Environment]::SetEnvironmentVariable("Path",[Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\Program Files\gs\gs9.55.0\lib;C:\Program Files\gs\gs9.55.0\bin;C:\ProgramData\chocolatey\lib\poppler\tools",[EnvironmentVariableTarget]::Machine)
```

**Restart VS Code** after installation.

<details>
<summary>Manual PATH setup</summary>

If you have issues setting PATH, add these manually via System Properties → Environment Variables:

```
C:\Program Files\gs\gs9.55.0\lib
C:\Program Files\gs\gs9.55.0\bin
C:\ProgramData\chocolatey\lib\poppler\tools
```

</details>
**Note:** Pre-0.6.0 versions required external installations of Ghostscript and Poppler. As of v0.6.0, these are **no longer required**! The extension now handles rendering internally using WebAssembly.

## Configuration

Configure custom executable paths in VS Code settings (useful for conda environments or non-standard installations):
The extension is zero-config!

| Setting | Description | Default |
| ------------------------------------ | ----------------------------- | ------------ |
| `postscript-preview.path.ps2pdf` | Path to ps2pdf executable | `ps2pdf` |
| `postscript-preview.path.pdftocairo` | Path to pdftocairo executable | `pdftocairo` |
| `postscript-preview.path.pdfinfo` | Path to pdfinfo executable | `pdfinfo` |

Example `settings.json`:

```json
{
"postscript-preview.path.ps2pdf": "/opt/ghostscript/bin/ps2pdf",
"postscript-preview.path.pdftocairo": "/opt/poppler/bin/pdftocairo"
}
```
Previous configuration settings (`postscript-preview.path.*`) have been deprecated and removed as they are no longer needed.

## Multi-Page Documents

Expand Down
24 changes: 3 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "postscript-preview",
"displayName": "PostScript Preview",
"description": "PostScript Preview is an extension that helps to preview EPS and PS files in Visual Studio Code.",
"version": "0.5.4",
"version": "0.6.0",
"icon": "images/logo.png",
"publisher": "ahnafnafee",
"engines": {
Expand Down Expand Up @@ -45,26 +45,6 @@
"group": "navigation"
}
]
},
"configuration": {
"title": "PostScript Preview",
"properties": {
"postscript-preview.path.ps2pdf": {
"type": "string",
"default": "ps2pdf",
"description": "Path to ps2pdf executable (from GhostScript). Use this if ps2pdf is not in your system PATH."
},
"postscript-preview.path.pdftocairo": {
"type": "string",
"default": "pdftocairo",
"description": "Path to pdftocairo executable (from Poppler). Use this if pdftocairo is not in your system PATH."
},
"postscript-preview.path.pdfinfo": {
"type": "string",
"default": "pdfinfo",
"description": "Path to pdfinfo executable (from Poppler). Used for detecting page count in multi-page documents."
}
}
}
},
"scripts": {
Expand All @@ -88,8 +68,10 @@
"typescript": "^5.9.3"
},
"dependencies": {
"@jspawn/ghostscript-wasm": "^0.0.2",
"@types/temp": "^0.9.4",
"glob": "^7.2.3",
"pdfjs-dist": "^5.4.449",
"temp": "^0.9.1"
},
"repository": {
Expand Down
20 changes: 8 additions & 12 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
/**
* Configuration management for PostScript Preview extension
* Configurations for PostScript Preview
*/
import * as vscode from "vscode";
import { ExtensionConfig } from "./types";

/**
* Get configuration values for executable paths
*/
export function getConfig(): ExtensionConfig {
const config = vscode.workspace.getConfiguration("postscript-preview");
return {
ps2pdf: config.get<string>("path.ps2pdf", "ps2pdf"),
pdftocairo: config.get<string>("path.pdftocairo", "pdftocairo"),
pdfinfo: config.get<string>("path.pdfinfo", "pdfinfo"),
};
export interface Config {
// No path configurations needed for internal rendering
}

export function getConfig(): Config {
// Return empty config or any future settings
return {};
}
58 changes: 1 addition & 57 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as vscode from "vscode";
import path = require("path");
import { PreviewState } from "./types";
import { generatePreview } from "./preview";
import { showWhatsNew } from "./whats-new";

/**
* Called when the extension is activated
Expand All @@ -18,7 +17,6 @@ export function activate(context: vscode.ExtensionContext): void {

if (isWindows) {
console.log("PostScript Preview: Checking for updates (Windows)...");
showWhatsNew(context);
}

const channel = vscode.window.createOutputChannel("PostScript-Preview");
Expand Down Expand Up @@ -49,64 +47,10 @@ export function activate(context: vscode.ExtensionContext): void {

const mainFilePath = document.fileName;

// Generate preview without awaiting (fire and forget)
generatePreview(mainFilePath, panel, channel);
channel.appendLine(`Watching ${filePath}`);

// Handle messages from webview for page navigation
panel.webview.onDidReceiveMessage(
(message) => {
const state = (panel as any).__previewState as
| PreviewState
| undefined;
if (!state) {
return;
}

switch (message.command) {
case "prevPage":
if (state.currentPage > 1) {
state.currentPage--;
generatePreview(
state.filepath,
panel,
channel,
state.currentPage,
state.pdfPath
);
}
break;
case "nextPage":
if (state.currentPage < state.totalPages) {
state.currentPage++;
generatePreview(
state.filepath,
panel,
channel,
state.currentPage,
state.pdfPath
);
}
break;
case "goToPage": {
const page = parseInt(message.page, 10);
if (page >= 1 && page <= state.totalPages) {
state.currentPage = page;
generatePreview(
state.filepath,
panel,
channel,
state.currentPage,
state.pdfPath
);
}
break;
}
}
},
undefined,
context.subscriptions
);

// Watch for file changes
const watcher = vscode.workspace.createFileSystemWatcher(filePath);
watcher.onDidChange((_: vscode.Uri) => {
Expand Down
Loading