Printing rubbish

Richmond Mathewson richmondmathewson at gmail.com
Mon Nov 30 15:57:09 EST 2009


On 11/29/09 11:33 AM, Jan Schenkel wrote:
> 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
>    

Thank you, Jan; that is really fantastic.

However, it would be lovely if there were a way to output to PDF/XPS/PS 
cross-platform as I know that XPS, for instance, is
problematic to read on a Mac and Linux systems that don't run KDE as a 
window manager.



More information about the use-livecode mailing list