Skip to content

PDF page size is ignored when printing on Linux #1409

@bratpeki

Description

@bratpeki

Discovered during development of automated testing.

Each Linux PDF print is the same size, despite them being configured for different sizes.
In the automated testing fork, the configs to individual PDF pages are defined here.

The Java printer always uses the CUPS default page size instead of the provided one.

The page size can be checked on localhost:631 > Administration > Manage Printers > the virtual PDF printer > Administration > Set Default Options > Page Size.


A pretty simple script to demonstrate the issue:

// qzbug.js

import qz from "./js/qz-tray.js"
import path from "node:path";

qz.api.setWebSocketType(WebSocket);
await qz.websocket.connect();

const samplePdfPath = path.resolve("assets/pdf_sample.pdf");

const data = [{
	type: 'pixel',
	format: 'pdf',
	flavor: 'file',
	data: "file://" + samplePdfPath
}];


const found = await qz.printers.find("pdf");

let config = qz.configs.create(
	found, { size: { width: 8.5, height: 11 }, units: "in" }
);
await qz.print(config, data);

config = qz.configs.create(
	found, { size: { width: 210, height: 297 }, units: "mm" }
);
await qz.print(config, data);

await qz.websocket.disconnect();
process.exit(0);

The first qz.print call makes ANSI A (Letter) and the latter makes A4.

Running these, I get:

[ ~/Code/GitHub/tray ]$ node qzbug.js
Established connection with QZ Tray on ws://localhost:8182
Failed to get certificate: undefined
Closed connection with QZ Tray

[ ~/Code/GitHub/tray ]$ cd ~/PDF

[ ~/PDF ]$ ls
Java_Printing-job_1695.pdf  Java_Printing-job_1696.pdf

[ ~/PDF ]$ pdfinfo *1695* | grep "Page size"
Page size:       612 x 792 pts (letter)

[ ~/PDF ]$ pdfinfo *1696* | grep "Page size"
Page size:       612 x 792 pts (letter)

Both are Letter!


@tresf has filed an upstream report with Liberica, mentioning that lpadmin -p PDF -o PageSize='...' can be used as a workaround, such that ... is "A4", "Letter", etc.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions