kooloveme / thtmlviewer

Automatically exported from code.google.com/p/thtmlviewer
Other
0 stars 0 forks source link

NumPrinterPages wrong #352

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is a re-opening of issue 197 (posted by somebody else in 2012 and closed 
some days ago): Yes, I also regularly have problems with NumPrinterPages, which 
appear for page counts of at least 5.

 1. Load a lengthy document into an THTMLViewer.
 2. Set the printer margins, etc.
 3. Call NumPrinterPages. In MOST cases, the return value will be
    correct, but sometimes not.
 4. Directly after this, call Print. This ALWAYS outputs the correct
    number of pages, which SOMETIMES is one more than returned from
    NumPrinterPages.
 5. For simple documents, this doesn't matter too much - one can just
    send them to the printer. But in case one has several chapters
    that should appear in the table of contents, one would like to use
    NumPrinterPages beforehand to get the starting pages (and the overall
    page count) correctly.

Unfortunately, the problem can NOT so easily be reproduced on another hardware, 
because it depends on the selected printer, the page size, the desired margins, 
the page scale, etc. Just slightly changing one of these parameters may produce 
the CORRECT result. If once a parameter combination has proved to return a 
wrong result for NumPrinterPages, this can reliably be reproduced, though, even 
across THTMLViewer versions.

Since the documents I use here are loaded as strings (NOT from a file) and 
contain PNG files read from an RCDATA program resource (NOT from a file), I 
will try to create some files out of that in the next time, so that you will 
hopefully be able to reproduce the problem. Let's see...

Original issue reported on code.google.com by weidner....@t-online.de on 13 May 2014 at 9:13

GoogleCodeExporter commented 9 years ago
Thanks Andreas,
a test file is much appreciated. 

I'd suggest to use a pdf printer like PdfCreator.
Would be the least expensive way to test printing ;)

Original comment by OrphanCat on 13 May 2014 at 10:32

GoogleCodeExporter commented 9 years ago
Attached is a minimum example project containing the following files:
 *.dfm, *.dpr, *.pas = the Delphi files
 *.html, *.png = the files for the text document
The files for the test document (being one chapter from the user manual of a 
small maths program I'm writing, which makes EXCESSIVE use of your wonderful 
HTML component) are searched in the same folder as the compiled EXE program.

The program has several printing settings. 'Scale' is used to effectively scale 
down the PNG files, so that they fit inside the print area width. When hitting 
'Print', NumPrinterPages is displayed, and DIRECTLY afterwards the document is 
sent to the printer, sometimes resulting in a DIFFERENT page number.

When using 'PDFCreator' as printer with A5 portrait page size and 600dpi under 
Windows 7, results are as follows:
 1. Left=20, Right=20, Top=18, Bottom=18, Font=Garamond 10pt, Scale=77:
    NumPrinterPages=9, Printout=10
 2. Left=20, Right=20, Top=18, Bottom=18, Font=Times New Roman 10pt, Scale=77:
    NumPrinterPages=Printout=11, but last page is empty
 3. Left=20, Right=20, Top=18, Bottom=18, Font=Minion Pro 10pt, Scale=77:
    NumPrinterPages=11, Printout=12
 4. Left=20, Right=20, Top=18, Bottom=18, Font=Tahoma 10pt, Scale=77:
    NumPrinterPages=11, Printout=12

When using 'PDF Creator' as printer with A4 portrait page size and 600dpi under 
Windows 7, results are as follows:
 5. Left=40, Right=20, Top=20, Bottom=20, Font=Times New Roman 12pt, Scale=100:
    NumPrinterPages=8, Printout=9
 6. Left=40, Right=20, Top=20, Bottom=20, Font=Courier New 12pt, Scale=100:
    NumPrinterPages=10, Printout=11
 7. Left=38, Right=20, Top=20, Bottom=20, Font=Times New Roman 12pt, Scale=100:
    NumPrinterPages=8, Printout=9
 8. Left=25, Right=20, Top=20, Bottom=20, Font=Minion Pro 12pt, Scale=100:
    NumPrinterPages=8, Printout=9

Try with other settings as follows:
 9. Select a font and some margin settings, so that the printout's last page is,
    say, roughly 30-40% filled.
10. Decrease the horizontal margin by 1mm, and check, whether NumPrinterPages
    also decreases. If not, cancel PDF Creator. If yes, print to PDF and check,
    whether the page count is larger than NumPrinterPages.

I hope the problem can be reproduced this way - thanks. 

Original comment by weidner....@t-online.de on 18 May 2014 at 7:05

Attachments: