Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^4: How to use wxHtmlEasyPrinting

by halweitz (Novice)
on Mar 18, 2013 at 21:29 UTC ( #1024156=note: print w/ replies, xml ) Need Help??


in reply to Re^3: How to use wxHtmlEasyPrinting
in thread How to use wxHtmlEasyPrinting

Thanks again. Your code was helpful although I am still not able to solve my issue. I reduced the margins to the minimum allowed by my printer but the rightmost few characters are still being truncated. Here is my code so far:

sub ShowPrintPreview { my ($self, $event) = @_; # Printout class for HTML documents my $printout = Wx::HtmlEasyPrinting->new("Printing", $htmlwindow); # Get pointer to PageSetupDialogData instance my $psd = $printout->GetPageSetupData(); # Set the margins to fit the page $psd->SetMarginTopLeft([3,3]); $psd->SetMarginBottomRight([3,3]); # Preview the text $printout->PreviewText($htmlcontent); }

I have tried to use SetFonts to reduce the font sizes on the preview page. The default sizes according to the wxwidgets.org are seven integers in the range -2 to +4. However only the third value, 0 seems to have any effect. When I change this from 0 to -1 the page text becomes too small to be readable. Changes to any of the other values seem to have no effect on the text size. Is there any way to scale the print out to fit a letter size page?


Comment on Re^4: How to use wxHtmlEasyPrinting
Download Code
Re^5: How to use wxHtmlEasyPrinting
by Anonymous Monk on Mar 19, 2013 at 09:07 UTC

    ... Here is my code so far:

    Sorry but that won't run, you're missing $htmlwindow -- compare to my example

    I have tried to use SetFonts to reduce the font sizes on the preview page. The default sizes according to the wxwidgets.org are seven integers in the range -2 to +4. However only the third value, 0 seems to have any effect. When I change this from 0 to -1 the page text becomes too small to be readable.

    Try positive integers, because the docs say

    sizes This is an array of 7 items of int type. The values represent size of font with HTML size from -2 to +4 ( <FONT SIZE=-2> to <FONT SIZE=+4> ). Default sizes are used if sizes is NULL.

    So wxHTML_FONT_SIZE_3 is size=-1 and wxHTML_FONT_SIZE_5 is size=+1 or some such combination

    So try positive integers, like these (the wxHTML_FONT_SIZE_ constants no longer appear to be public )

    Is there any way to scale the print out to fit a letter size page?

    Sorry, I don't know. I imagine its possible, see
    wxperl_demo --show wxPrintPaperDatabase
    wxperl_demo --show wxPrinting

    If you look inside Wx::DemoModules::wxPrinting you'll see a wxPrintout subclass calling a wxDC::SetUserScale, centers/resizes the image -- but I've never tried it

      Ok, I'll try something along those lines. I don't really understand how defining larger values will result in a smaller printout but I won't know until I try. BTW the constructor for $htmlwindow is in the initialization subroutine.

        I don't really understand how defining larger values will result in a smaller printout

        Me neither, but it might have some effect on the text being unreadable -- if you start up notepad and try specifying font size as zero or negative , I get something quite unreadable. If you use font sizes smaller than default but still readable, it might work :/

        BTW the constructor for $htmlwindow is in the initialization subroutine.

        :) yes, I assumed as much, but that doesn't help the code run on my computer

        OK. Your suggestion on the font sizes worked correctly. Many thanks. If it moves you, I would like to know your thought process to make that suggestion.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024156]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-12-26 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls