http://qs1969.pair.com?node_id=1023866


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

Thanks for the reply. I installed Wx and Wx::Html (and a few others) last month so I'm pretty sure everything is up to date. The info on ::SetMarginTopLeft says this:

wxPageSetupDialogData::SetMarginTopLeft void SetMarginTopLeft(const wxPoint& pt)

Sets the left (x) and top (y) margins in millimetres.

So, I think I need to pass an object of type wxPoint. Point has a constructor, two methods, Get, Set, and two properties, x, and y of type int. So, I code the following to set the properties to 5 millimeters.:

my $point = Wx::Point->new; $point->Set(x=>5); $point->Set(y=>5);

This gives me the following error: Can't locate object method "Set" via package "Wx::Point"

So, I give up on that and instead pass an x, y pair as an array just to see what happens:

my $printhtml = Wx::HtmlEasyPrinting->new(); my $psd = $printhtml->GetPageSetupData; #returns a pointer to PageSetu +pDialogData $psd->SetMarginBottomRight( [ 5, 5 ] );

This gives me the following error message:

usage: Wx::PageSetupDialogData::SetMarginBottomRight(THIS, point)

So, now I see that it takes two parameters and I am still left with the question of how to specify the parameters (THIS, and point). BTW, I am very new to Perl and many of the examples assume far more Perl knowledge than I currently posses. A fleshed out working example would be GREATLY appreciated.

Replies are listed 'Best First'.
Re^3: How to use wxHtmlEasyPrinting
by Anonymous Monk on Mar 17, 2013 at 09:24 UTC

    So, I code the following to set the properties to 5 millimeters.:

    funny, where do you get that from?

     Wx::Point->new( x, y );

    my wxWidgets / wxPerl / wxGlade tutorial, http://www.wxperl.it/p/wxperl-primer.html

    A fleshed out working example would be GREATLY appreciated.

    :) I've no interest starting from scratch

    use Wx qw' :allclasses '; my $psdd = Wx::PageSetupDialogData->new; my $p = $psdd ->GetMarginBottomRight; print $p->y, ' ', $p->x, "\n"; $psdd->SetMarginBottomRight([6,6]); $p = $psdd ->GetMarginBottomRight; print $p->y, ' ', $p->x, "\n"; __END__ 0 0 6 6

      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?

        ... 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