Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How to use wxHtmlEasyPrinting

by Anonymous Monk
on Mar 16, 2013 at 03:47 UTC ( #1023805=note: print w/ replies, xml ) Need Help??


in reply to How to use wxHtmlEasyPrinting

??

http://docs.wxwidgets.org/stable/wx_wxhtmleasyprinting.html
wxHtmlEasyPrinting::GetPrintData
wxHtmlEasyPrinting::GetPageSetupData
wxPageSetupDialogData::SetMarginTopLeft

$ perl -MWx=:allclasses -le " print for grep/set/i, keys %Wx::PageSetu +pDialogData:: " SetPaperSize SetDefaultMinMargins SetMinMarginBottomRight SetMinMarginTopLeft SetPrintData SetMarginTopLeft SetPaperId SetDefaultInfo SetMarginBottomRight

also, mind your wxWidgets version


Comment on Re: How to use wxHtmlEasyPrinting
Download Code
Re^2: How to use wxHtmlEasyPrinting
by halweitz (Novice) on Mar 17, 2013 at 01:19 UTC

    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.

      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?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2014-09-24 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (244 votes), past polls