Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^5: How to use wxHtmlEasyPrinting

by Anonymous Monk
on Mar 19, 2013 at 09:07 UTC ( #1024239=note: print w/replies, xml ) Need Help??

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

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

#ifdef __WXMSW__ #define wxHTML_FONT_SIZE_1 7 #define wxHTML_FONT_SIZE_2 8 #define wxHTML_FONT_SIZE_3 10 #define wxHTML_FONT_SIZE_4 12 #define wxHTML_FONT_SIZE_5 16 #define wxHTML_FONT_SIZE_6 22 #define wxHTML_FONT_SIZE_7 30 #elif defined(__WXMAC__) #define wxHTML_FONT_SIZE_1 9 #define wxHTML_FONT_SIZE_2 12 #define wxHTML_FONT_SIZE_3 14 #define wxHTML_FONT_SIZE_4 18 #define wxHTML_FONT_SIZE_5 24 #define wxHTML_FONT_SIZE_6 30 #define wxHTML_FONT_SIZE_7 36 #else #define wxHTML_FONT_SIZE_1 10 #define wxHTML_FONT_SIZE_2 12 #define wxHTML_FONT_SIZE_3 14 #define wxHTML_FONT_SIZE_4 16 #define wxHTML_FONT_SIZE_5 19 #define wxHTML_FONT_SIZE_6 24 #define wxHTML_FONT_SIZE_7 32 #endif

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

Replies are listed 'Best First'.
Re^6: How to use wxHtmlEasyPrinting
by halweitz (Novice) on Mar 19, 2013 at 14:28 UTC

    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.

        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.

        Glad it helped

        Well, I read what you tried, I read the documentation, and compared what you tried to my understanding of the docs (including html), and I examined what the values of the constants were

        Basically , you verify everything starting with the problem-causing-line until you encounter a difference between what you think should happen and what you observe to happen -- usually these revelations are loud AHA!-types with a solution, or so confusing that you're forced to put-aside what you're working on and start a new file to create the smallest possible example that replicates the problem

        Its a lot like debugging CGI scripts or any kind of program, you need a mental model of how its supposed to work (Cwd, STDIN/STDERR/STDOUT/@ARGV/%ENV), what is special about perl ( PERLLIB/PERL5LIB/PERL5OPTS, perlvar, @INC ), what is special about CGI (Server error, see CGI Help Guide , Troubleshooting Perl CGI scripts)

        You know input comes on STDIN, output goes on STDOUT, and if things stop making sense and you haven't been able to force an error message, you start making your own error message (turn on debugging/logging, add print statement), you start verifying that STDIN contains the input that is supposed to be there, that pwd/cwd is what you think it should be, and %ENV, and @ARGV ... and @_ are what the function takes

        You always start with the big picture, an overview(like wxWidgets overviews), a bird's eye view of how something is supposed to work ( like HTTP ), then look at some simple examples, then bigger examples, until the big idea is firmly planted in your headn. Then write lots of little programs to explore/test/verify how each part is supposed to and does work.

        Then when debugging a real program, you have a built-in debugging checklist to verify against. If you're well designed libraries (Dancer/Catalyst...) they'll do a lot of the checking for you, make errors obvious, but you'll be lost without a mental model (aka "domain" or metaphor) , error messages won't make sense, and programmers need a few just to get started (stdin, args, return values, exit codes, files and folders/directories ...)

        Its a lot like being a car mechanic or an animal tracker, you start with a model/behaviour of a car/animal, you look to see what tracks/diagnostics you're getting, you ask yourself, if I were fuel/camel and I were leaking/thirsty, which way would I turn? And then turn left/replace leaky carburetor :) How Non-scientists use the Scientific Method

        a lot more links on this type of thing and related things and examples if you've got time and need some perspectives and perspectives

        Also known as teddy bear debugging , mirror debugging, empty room debugging, talking to yourself, Rubber Duck method of debugging, say it out loud George, sing into that hairbrush ... Re^3: Move along, nothing to see here . . ., Re: On Answering Questions

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024239]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2018-02-24 02:27 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (310 votes). Check out past polls.