Printing rubbish

Jan Schenkel janschenkel at yahoo.com
Sun Nov 29 04:33:10 EST 2009


Hi Richmond,

Printing in rev can be a bit confusing at times, but I have some experience with it so I can help you find the errors in your ways ;-)

Let's start at the top. In order to print a card to a PDF file, you have to do a little more than what you scripted:
##
on mouseUp
   local tFilePath
   put specialFolderPath("desktop") & "/test.pdf" into tFilePath
   set the printerOutput to ("file:" & tFilePath)
   set the printMargins to 0,0,0,0
   print this card
   launch document tFilePath
end mouseUp
##
I decided to place the file on the desktop and launch it right after printing. The key difference was setting the printMargins. If your 'print' command doesn't specify an 'into' rectangle, the engine assumes you're printing from the top left of the printable part of the paper.

Important to know, so you get your expectations right:
- graphic objects are printed to 'unlimited' precision, zooming in shouldn't result in jagged lines
- the text in objects (fields, button labels, etc.) are also printed to 'unlimited' precision
- everything else (images, players and other controls) gets printed at 'screen' precision and will show jaggies as you zoom in

The reason is simple: rev asks the operating system to draw a button, but gets this back as a bitmap; it then prints the label of the button on top of it; these are two distinct graphic environments, and while you don't see it on screen, you'll see the difference upon printing time.

Anyway, on to the problem of printing a field. The simplest method is indeed to use the revPrintField command, so you ware almost there:
##
on mouseUp
   local tFilePath
   put specialFolderPath("desktop") & "/test2.pdf" into tFilePath
   set the printerOutput to ("file:" & tFilePath)
   revShowPrintDialog false, false
   revPrintField the long id of field "MyStyledTextField"
   launch document tFilePath
end mouseUp
##
Calling the 'revShowPrintDialog' command allows you to control which dialogs are shown (page setup, print) so by passing false twice, we bypass the dialog box completely. And the PDF output looked crispy on my Mac.

On Windows, you can use the printerOutput to create 'XPS' files (MS alternative to PDF), and on Linux, you can use it to create 'PS' files (PostScript, of course)

HTH,

Jan Schenkel
=====
Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


--- On Sat, 11/28/09, Richmond Mathewson <richmondmathewson at gmail.com> wrote:

> From: Richmond Mathewson <richmondmathewson at gmail.com>
> Subject: Printing rubbish
> To: "How to use Revolution" <use-revolution at lists.runrev.com>
> Date: Saturday, November 28, 2009, 8:18 AM
> I have a card containing a field that
> is 875 wide (on a Mac),
> so when I do this:
> 
> on mouseUp
>    set the printerOutput to "file:
> Rubbish.pdf"
>    print this card
> end mouseUp
> 
> I get rubbish insofar as i get the left half of
> the card in a PDF file; wonder what happened to the
> right half?
> 
> ----------------------------------------------------------
> 
> Of course this:
> 
> on mouseUp
>    set the printerOutput to "file:
> RubbishToo.pdf"
>    print fld "fTEXT"
> end mouseUp
> 
> just throws a "bluey"!
> 
> A bit of a shame, really, as printing from text-fields
> would
> be ever-so nifty.
> 
> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
> 
> I wonder whether this:
> 
> "Output direct to PDF
> Cards or portions of cards can now be output direct to pdf
> format files."
> 
> means that one can do this in Supercard ????
> 
> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
> 
> This:
> 
> on mouseUp
>    set the printerOutput to "file:
> RubbishToo.pdf"
>    print this card from 204,159 to 764,561
> end mouseUp
> 
> proved interesting as it printed out most of the field
> (204,159 being the field's top-left
> and 764,561 being its bottom-right), but chopped off its
> right side (presumably the
> field is too wide).
> 
> -----------------------------------------------------------------------
> 
> Of course, printing a scrolling field to PDF would have
> been a
> non-starter as what is REALLY being printed is a SNAPSHOT
> of all
> or part of the card.
> 
> -----------------------------------------------------------------------
> 
> Tried this:
> 
> on mouseUp
>    set the printerOutput to "file:
> RubbishToo.pdf"
>    revPrintField ("field" &&
> "fTEXT")
> end mouseUp
> 
> and got a printer dialogue; and, interestingly enough, not
> the
> standard Mac OS X one where there is the option to output
> to PDF.
> 
> ---------------------------------------------------------------------
> 
> So, for now (at least) outputting a whole field to PDF on
> Mac looks
> fairly hopeless.
> 


      



More information about the use-livecode mailing list