Mapbasic -- Batch printing jpgs

153 views
Skip to first unread message

hendrik

unread,
Jul 27, 2007, 7:08:49 AM7/27/07
to MapInfo-L
Dear list,

i have a problem printing layout windows into jpgs in batchmode.

First i open a wor.
Then i want to print the Layout window into a jpg. (A3 format)
Save windows as
close wor
open next wor

My problem is to determine if the layout is landscape or portrait.
The variables ( fltWinheight, fltWinwidth) always lead to the result
its landscape:

Does anybody know whats wrong?
Does anybody have an idea if theres abetter way?

I am using:
Mapinfo 7.8
Mapbasic 7.0
(can upgrade to 8.0)


Heres my code:

Run Application " ***.WOR"

If Not FrontWindow() Then
Note "open Layout"
Exit Sub
ElseIf WindowInfo(FrontWindow(),WIN_INFO_TYPE) <> WIN_LAYOUT Then
Note "Layout window must be Front"
Exit Sub
End If

ifrontwin = FrontWindow()
fltWinheight = WindowInfo(ifrontwin, WIN_INFO_HEIGHT)
fltWinwidth = WindowInfo(ifrontwin, WIN_INFO_WIDTH)

Print "fltWinheight "+ fltWinheight
print "fltWinwidth "+ fltWinwidth


'Now this does

If fltWinheight >fltWinwidth then

Save Window ifrontwin
As "***.jpg"
Type "JPEG"
Width 29.69 Units "cm"
Height 41.28 Units "cm"
Resolution 150

Else

Save Window ifrontwin
As "***.jpg"
Type "JPEG"
Width 41.28 Units "cm"
Height 29.69 Units "cm"
Resolution 150

End If

Thanks in Advance.

Hendrik

Timothy Mashford

unread,
Jul 28, 2007, 1:29:54 AM7/28/07
to mapi...@googlegroups.com
Hendrik,

The WIN_INFO_HEIGHT and WIN_INFO_WIDTH give the dimensions of the
layout window, not the paper - which is what you want.

To work out if it's landscape or portrait, use

WindowInfo(iFrontWin, WIN_INFO_PRINTER_ORIENT)

which returns WIN_PRINTER_PORTRAIT (1) for portrait, and
WIN_PRINTER_LANDSCAPE (2) for landscape.

Tim Mashford.

Reply all
Reply to author
Forward
0 new messages