OpenPrinting / OpenPrinting/cups-filters

Can't set margins in texttopdf 2.0.0?

Open
#577 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
197
Forks
158
Avg merge
3h 29m
Merged PRs (30d)
1

Description

Describe the bug
texttopdf from cups-filters 2.0.0 (version used in the OpenBSD package cups-filters) doesn't seem to respect the page-* option(s).

To Reproduce
Steps to reproduce the behavior:

/usr/local/libexec/cups/filter/texttopdf 1 user title 1 'media=A4 page-left=56' \
/etc/passwd > p.pdf
/usr/local/libexec/cups/filter/texttopdf 1 user title 1 'media=A4' /etc/passwd > p2.pdf
  1. Open both files: p.pdf, and p2.pdf in a PDF viewer.
  2. See error - left margin is the same in both files.

Expected behavior
Left margin should be increased to about 2cm in the file p.pdf (generated with the option page-left=56).

Screenshots
2024-03-04-194832-dwm

System Information:

  • OS: OpenBSD-release 7.4
  • cups-filters version 2.0.0

Additional context
For example, Alpine Linux has cups-filters 1.28.17 fixed as the last upstream release they use for building the cups-filters package. With that version of cups-filters, the command

/usr/lib/cups/filter/texttopdf 1 user title 1 'page-left=56' /etc/passwd > p.pdf

produces a PDF file with the left margin set to about 2cm. A similar command in OpenBSD:

/usr/local/libexec/cups/filter/texttopdf 1 user title 1 'page-left=56' /etc/passwd > p.pdf

complains:

DEBUG: Color space requested: Default
DEBUG: Final output format: CUPS Raster
WARN: Could not determine the output page dimensions, falling back to US Letter format
WARN: cfFilterPDFToPDF: Could not determine the width of the left margin, falling back to 18 pt/6.35 mm
WARN: cfFilterPDFToPDF: Could not determine the width of the bottom margin, falling back to 36 pt/12.7 mm
WARN: cfFilterPDFToPDF: Could not determine the width of the right margin, falling back to 18 pt/6.35 mm
WARN: cfFilterPDFToPDF: Could not determine the width of the top margin, falling back to 36 pt/12.7 mm

when given the additional parameter of media=A4 (A has to be uppercase, unlike with 1.28.17!):

/usr/local/libexec/cups/filter/texttopdf 1 user title 1 'media=A4 page-left=56' \
/etc/passwd > p.pdf

the output is reduced to

DEBUG: Color space requested: Default
DEBUG: Final output format: CUPS Raster

and there is no difference in the generated PDF from

/usr/local/libexec/cups/filter/texttopdf 1 user title 1 'media=A4' /etc/passwd > p2.pdf

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the texttopdf filter entry point and reproduce the issue using the OpenBSD commands in the report, comparing output with cups-filters 1.28.17. The work is done when page-left=56 changes the generated PDF margin while media=A4 is supplied, without the reported fallback warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.