Bug 2219360

Summary: html2ps creates multi page empty postscript
Product: [Fedora] Fedora Reporter: Paul Dwyer <pdwyer>
Component: html2psAssignee: Petr Pisar <ppisar>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 38CC: kasal, ppisar, rdieter
Target Milestone: ---Keywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: html2ps-1.0-0.48.b7.fc39 html2ps-1.0-0.48.b7.fc38 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-07-13 01:28:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Paul Dwyer 2023-07-03 10:18:23 UTC
When converting an html file to postscript, the output postscript file appears to be empty and contains many more pages that the original html file.

Reproducible: Always

Steps to Reproduce:
Content of html page does not matter (original test was simple html page containing an image)
1. html2ps test.html > test.ps 
2. view postscript file with postscript viewer such as ghostscript or convert to another format such as pdf (ps2pdf)

Actual Results:  
test.ps file has many more (blank) pages than the original test.html file

Expected Results:  
Content from html to be displayed in postscript file

Upon further investigation I believe the content is in the postcript file but the drawable area of the pages is offscreen as the page dimensions are wrong.

I have been comparing html2ps output generated on Fedora 28 with html2ps output generated on RHEL7 (html2ps is not available on RHEL8 or RHEL9) and the major difference was page dimensions.

When running html2ps on Fedora it also generates the following error
"Unknown paper type: A4: 210x297 mm"

Paper dimensions are obtained from `paper` command and recently it looks like this was switched from `paperconf` (which is not available on Fedora 38).

29 $default_paper=`paper` || 'a4';
...
48     type: $default_paper;
...
616 if(!$pagew || !$pageh) {
 617   if($width{"\L$paper{'type'}"}) {
 618     $paper{'width'}=$width{"\L$paper{'type'}"} if(!defined $paper{'width'});
 619     $paper{'height'}=$height{"\L$paper{'type'}"} if(!defined $paper{'height'});
 620     ($pagew,$pageh)=($paper{'width'},$paper{'height'});
 621   } elsif($paper{'type'}) {
 622     &dbg("Unknown paper type: $paper{'type'}\n");
 623   }

I can workaround this by setting my own ".html2psrc" config file and adding a paper configuration e.g.

  paper {
    type: A4;
    height: "29.7";
    width: "21.0";
  }

Without any paper settings in config file I get page dimensions (notice the negative offset)

/yL -84 D
/yR -84 D
/Wl -141 F div D
/Wr -141 F div D
/hL -169 F div D
/hR -169 F div D

It looks like the output from `paper` is not a drop in replacement for `paperconf` from previous versions as output is significantly different.

I assume this is not a major issue to most people as they probably have their own specific "html2psrc" configuration

Comment 1 Petr Pisar 2023-07-04 12:22:33 UTC
I see. spot replaced the dependency from paperconf to paper without checking the output.

"paperconf" command only printed a paper name. E.g. "a4".
"paper" command prints the name followed with the dimensions. E.g. "A4: 210x297 mm".

paper has --no-size option. I will try to adapt html2ps.

Comment 2 Paul Dwyer 2023-07-04 12:50:42 UTC
Changing this line in html2ps

29 $default_paper=`paper` || 'a4';

to

29 $default_paper=`paper --no-size` || 'a4';

works for me

Comment 3 Fedora Update System 2023-07-04 13:14:53 UTC
FEDORA-2023-7fec006000 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-7fec006000

Comment 4 Fedora Update System 2023-07-05 01:19:36 UTC
FEDORA-2023-7fec006000 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-7fec006000`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-7fec006000

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2023-07-13 01:28:55 UTC
FEDORA-2023-7fec006000 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.