Skip to content

Commit

Permalink
cfFilterTextToPDF(): If no output page dimensions specified, use Letter.
Browse files Browse the repository at this point in the history
Before, the page dimensions were set to 0x0, ending up with one empty
page per character in the input file being produced.
  • Loading branch information
tillkamppeter committed Dec 5, 2022
1 parent 52d26b8 commit 2e25fb8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## CHANGES IN V2.0b2 (TBA)

- cfFilterTextToPDF(): If no output page dimensions specified, use US
Letter. Before, the page dimensions were set to 0x0, ending up with
one empty page per character in the input file being produced.

- cfFilterPDFToPDF(): Initialize output page dimensions to easily
identify if no dimensions were supplied, to fall back to default
size Letter. Otherwise we get invalid PDF output if we do not
Expand Down
14 changes: 14 additions & 0 deletions cupsfilters/texttopdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,20 @@ cfFilterTextToPDF(int inputfd, // I - File descriptor input stream
}
}

if (doc.PageWidth <= 0.0 || doc.PageLength <= 0.0 ||
doc.PageLeft >= doc.PageRight ||
doc.PageBottom >= doc.PageTop)
{
if (log) log(ld, CF_LOGLEVEL_WARN,
"cfFilterTextToPDF: No valid page dimensions specified, using US Letter.");
doc.PageLeft = 18.0f; // Left margin
doc.PageRight = 594.0f; // Right margin
doc.PageBottom = 36.0f; // Bottom margin
doc.PageTop = 756.0f; // Top margin
doc.PageWidth = 612.0f; // Total page width
doc.PageLength = 792.0f; // Total page length
}

if ((val = cupsGetOption("wrap", data->num_options, data->options)) == NULL)
doc.WrapLines = 1;
else
Expand Down

0 comments on commit 2e25fb8

Please sign in to comment.