Git Product home page Git Product logo

ppm2pwg's Introduction

ppm2pwg - misc printing utilities

(should really be renamed)

C/C++ CI CodeQL

Available as rudimentary standalone applications, but mainly made for use in SeaPrint.

ppm2pwg

Takes a pbm, pgm or ppm (P4, P5 or P6 "raw") Netpbm bitmap image and converts to PWG or URF printer raster format.

...or a raw bitmap in the c++ api.

pwg2ppm

For debugging. Similar to rasterview, but without a GUI. Takes a PWG or URF printer raster and outputs a series of P4, P5 or P6 pbm/pgm/ppm images.

pdf2printable

Takes a PDF document and makes it suitable for printing, by:

  • rotate and scale to fit as needed to a desired page size
  • convert to PDF 1.5, Postscript 2 or PWG/URF raster

baselinify

Takes a JPEG and losslessly repacks it to the baseline ecoding profile, keeping only JFIF and Exif headers. Sort of like jpegtran without any arguments, but reusable in C++.

IPP-printers are only required to support baseline-encoded jpeg according to PWG5100.14.

Despite working with in-memory data, it only requires the libjpeg 62.2.0 and not 62.3.0/7.3+ API, so it works on conservative distros.

ippclient

An IPP client that harnesses the above tools for converting files to be printed. This is a port/rewrite/clean-up of the core parts of SeaPrint in regular (non-Qt) C++. The plan is to swap over to using this once fature parity is achieved.

Building

Install dependencies:

sudo apt install libpoppler-dev libpoppler-glib-dev libcairo2-dev libglib2.0-dev libjpeg-dev libcurl4-openssl-dev zlib1g-dev

Build:

make -j$(nproc)

pdf2printable vs the competition

(As of 2024-03-02)

A bit of friendly comparison helps make sure the featureset is well-rounded and performance is on par.

Basics

PDF renderer Language License
pdf2printable Poppler C++ GPL3
ipptransform XPDF or Poppler C Apache 2.0
mutool MuPDF C AGPL or commercial
jrender Apache PDFBox Java/Kotlin MIT

Not in the running: cups-filters (can't get them to run outside CUPS), Android/Apple built-ins and Google Cloud Print (not available standalone).

Format support

PDF Postscript PWG URF PCLm¹ PCL²
pdf2printable
ipptransform ✔³
mutool
jrender

Good printers should support PDF or PWG. After that, URF is the biggest enabler.

  1. I have not yet seen a printer support PCLm and none of the other formats that pdf2printable supports.
  2. PCL comes in many different dialects (even beyond the versions) so it might not work across all printers.
  3. Pre-rasterized compatibility version.

Features

back-xform¹ color modes ² rotate-to-fit page selection stdout
pdf2printable ✔(6) ✔(+stdin)
ipptransform ✔(5)
mutool ✔(3?)
jrender ✘(1)³
  1. PWG, URF and PCLm printers may require the client to help transform backside pages for duplex printing, or they will come out incorrectly.
  2. Two color modes (sRGB24 and sGray8) is enough for basically anything.
  3. Jrender can be patched to do gray or bi-level, but the output is broken.

Performance

Measured with a representative 90-page document for PWG-raster at 600 DPI on a AMD 3950X.

Speed (RGB) Speed (Gray) Size (RGB) Size (Gray)
pdf2printable 9s 9s 152MB 76MB
ipptransform 26s 27s 159MB 76MB
mutool (AA off) 19s 26s 152MB 76MB
jrender (600dpi patch) 25s N/A 334MB¹ N/A
  1. Antialiasing seems to be enabled and would account for the size difference. However, at these resolutions that doesn't really provide much benefit. For pdf2printable and mutool it can be optionally enabled/disabled.

ppm2pwg's People

Contributors

attah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ppm2pwg's Issues

undefined reference to `poppler_document_new_from_fd'

I'm trying to compile pdf2printable on Tiny Core Linux, using poppler 23.09.0.

After I install all dependencies, the make step fails:

$ git clone https://github.com/attah/ppm2pwg.git
$ cd ppm2pwg
$ git clone https://github.com/attah/bytestream.git
$ make pdf2printable
---snip---
/usr/local/bin/ld: /tmp/ccNWELeR.ltrans1.ltrans.o: in function `pdf_to_printable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::function<bool (unsigned char const*, unsigned int)>, PrintParameters const&, std::function<void (unsigned long, unsigned long)>, bool)':
<artificial>:(.text+0x60db): undefined reference to `poppler_document_new_from_fd'
collect2: error: ld returned 1 exit status
make: *** [Makefile:25: pdf2printable] Error 1

Any ideas how to move past this error?

what are acceptable strings for --paper-size?

Hi, attah. Thank you very much for pdf2printable, which I use in a shell script to print (by sending PWG to network printer using ipptool). All GNU/Linux computers in my household (mine, wife's, and children's) use this script :) I use pdf2printable rather than mutool because it is so wonderfully minimalistic.

So far I have only needed to use my printer's default paper size (8.5 x 11 inches, aka "letter") and printing "just works" without having to specify paper size to pdf2printable or to ipptool. But I'd like to learn how to print to different paper size (e.g., 8.5 x 14 inches, aka "legal") just in case I need it someday.

I have two questions, please:

  1. Where can I find a list of acceptable strings for pdf2printable --paper-size?
  2. If PWG has been created with pdf2printable --paper-size foo, do I need to specify foo again when using ipptool to send the PWG to printer, or does ipptool automatically determine the paper size based on PWG's dimensions?

no MediaBox in pdf created using pdf2printable

I primarily use pdf2printable to convert pdf to pwg for printing. For this, pdf2printable works flawlessly. Kudos!

Since I already have pdf2printable on my system, I would rather not install a separate utility (e.g., pdftk) for those rare times when I have to rearrange pages in a pdf. I've found that I can use pdf2printable with --pages flag for this purpose, like so:

$ pdf2printable --pages <pages> <inputpdf> <outputpdf>

The only problem I've noticed is that the input pdf file's metadata (I'm specifically interested in MediaBox) is absent from the output pdf:

$ strings input.pdf | grep -m1 MediaBox
---snip---/MediaBox[ 0 0 612 792] ---snip---
$ pdf2printable --pages 1-3,5,7 input.pdf output.pdf
$ strings output.pdf | grep -m1 MediaBox
$ 

Would it be possible to tweak pdf2printable so that it includes metadata (at least MediaBox) in the output file when the output file is a pdf? Having MediaBox is very handy for certain kinds of further manipulation.

P.S. If outputting to pdf is too far outside pdf2printable's intended usage to justify this kind of tweak, I completely understand.

pdf2printable default page size

Sorry to bother again. I noticed that pdf2printable defaults to A4 page size for output files. I was a surprised by that--I expected that if size is not specified, output file would have same page size as input file. What are your thoughts about this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.