Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing PDFs has a cross-platform solution: Ghostscript #33

Open
lchjczw opened this issue Feb 2, 2025 · 4 comments
Open

Printing PDFs has a cross-platform solution: Ghostscript #33

lchjczw opened this issue Feb 2, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@lchjczw
Copy link

lchjczw commented Feb 2, 2025

There is a cross-platform solution for printing PDF files: Ghostscript.

Here are three implementation options:

Option 1: Cross-platform via Ghostscript's WASM implementation:
Ghostscript WASM
The advantage is ease of integration.

Option 2: Cross-platform via Ghostscript API binding:
https://github.com/albel727/rust-ghostscript

Option 3: Cross-platform via Ghostscript's binary file, using the command line:
gs -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%printer%printer_name input.pdf

Two approaches:

Convert the PDF to a PS file, and then send the PS file to the printer (Option 1, Option 2, and Option 3 can all be used).
Send the PDF directly to the printer using Ghostscript (Option 1 might require WASI, but Option 2 and Option 3 can both do this).

Overall, Option 2 is the best.

打印PDF文件的跨平台方案有ghostscript。

这里有两个实现方案:

方案1:通过ghostscript的wasm实现跨平台:
ghostscript wasm
优点是接入比较方便

方案2:通过ghostscript的api bind实现跨平台:
https://github.com/albel727/rust-ghostscript

方案3:通过ghostscript的二进制文件,通过命令行:
gs -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%printer%printer_name input.pdf

两种思路:
1.将PDF转为ps文件,然后将ps文件发送给打印机 (方案1和方案2,方案3都可以)
2.直接ghostscript将PDF发送到打印机(方案1可能需要wasi,方案2和方案3都可以)

综合来看,方案2是最好的

@lchjczw
Copy link
Author

lchjczw commented Feb 2, 2025

Ghostscript supports static compilation.

@lchjczw
Copy link
Author

lchjczw commented Feb 2, 2025

CUPS printing PDF files relies on Ghostscript.

@jonahgeorge
Copy link

I believe this would require re-licensing the project as AGPL?

https://www.ghostscript.com/licensing/

@talesluna talesluna added the enhancement New feature or request label Feb 5, 2025
@lchjczw
Copy link
Author

lchjczw commented Feb 5, 2025

Rust Bind can use dynamic linking or

or use dynamic linking ,Only as an optional dependency, in compliance. rust-printers does not enforce binding to Ghostscript, and the user assumes responsibility for AGPL obligations.

Clearly distinguish license responsibilities to ensure that users comply with AGPL requirements during integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants