Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

DataWindow printing - Margins

7 posts in DataWindow Last posting was on 2008-08-08 01:31:28.0Z
Daniel dcferreira [at] attps [.] com [.] br Posted on 2008-08-06 15:11:32.0Z
Sender: 6388.4899b932.846930886@sybase.com
From: Daniel dcferreira [at] attps [.] com [.] br
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: DataWindow printing - Margins
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4899bf24.64e3.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 6 Aug 2008 08:11:32 -0700
X-Trace: forums-1-dub 1218035492 10.22.241.41 (6 Aug 2008 08:11:32 -0700)
X-Original-Trace: 6 Aug 2008 08:11:32 -0700, 10.22.241.41
Lines: 59
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:87501
Article PK: 416756

Hi guys,

I've searched the forums, haven't found an working answer,
maybe you can help me. Not sure if this is a DW or PS
question.

I'm so frustrated not to get this working yet, hope you can
help...

Scenario:
We have a product, PB built, with many reports on it. We
have many different customers, each with his own different
printer.
Our reports are built using the DW landscape or portrait
accordingly, default to A4 paper.
A few customers have Letter paper, other have Ink-jet
printers with large "non-printable" margins.

What I want:
I want to see the available printable area that I can use,
on each customer/printer, and adjust the
DataWindow.Print.Scale or DataWindow.Zoom property to print
on only 1 page what is meant to be print on only 1 page, ie,
some reports, on some customers/printers, are resulting in
blank pages (or pages with little "cut" information) being
print as horizontal pages inadequately, because of their
large non-printable margins.

My current steps:
I have managed to get the printer page size (using APIs),
and I am using the DW on Print Preview, to see the correct
page numbers. I can "see" on the report the non-printable
margins (PB puts them by default I guess), specific for the
current printer, but I don't seem to get the size of these
margins through PSscript, to do my calculations of the scale
adjustment.
I have tried to find some printer property for it, but
haven't found any yet. I have tried the
DW.Object.DataWindow.Print.Margin.Bottom (for example), but
even on PrintPreview, it returns the margin I've set for the
report on first place, not the margin I see on the DWs
PrintPreview for that printer...

Please, how can I get the non-printable margins of my
report, for the current printer? The one I see on the report
when I put it on PrintPreview!!!!

By the way, I'm using PB8.

Thank you all guys, really!

PS. There's a "bug" in PB8 (not sure about more recent
versions). When you have a DW in portrait, all fields
fitting in portrait, and you change it dynamically to
landscape (ajusting the page orientation, and putting 1 or
more dw columns or texts a bit larger than portrait), when
you ajust it back to portrait (shrinking the field back to
original and putting the orientation back on portrait), it
prints an blank page as horizontal page... always.


Daniel dcferreira [at] attps [.] com [.] br Posted on 2008-08-06 18:31:17.0Z
Sender: 6388.4899b932.846930886@sybase.com
From: Daniel dcferreira [at] attps [.] com [.] br
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: DataWindow printing - Margins
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4899edf5.6c02.1681692777@sybase.com>
References: <4899bf24.64e3.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 6 Aug 2008 11:31:17 -0700
X-Trace: forums-1-dub 1218047477 10.22.241.41 (6 Aug 2008 11:31:17 -0700)
X-Original-Trace: 6 Aug 2008 11:31:17 -0700, 10.22.241.41
Lines: 3
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:87504
Article PK: 416757

I think I'll be able to achieve it using other API calls
(GetDeviceCaps). I'll post the solution if it works.
Daniel


Daniel dcferreira [at] attps [.] com [.] br Posted on 2008-08-06 21:45:40.0Z
Sender: 6388.4899b932.846930886@sybase.com
From: Daniel dcferreira [at] attps [.] com [.] br
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: DataWindow printing - Margins
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <489a1b84.6f1b.1681692777@sybase.com>
References: <4899edf5.6c02.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 6 Aug 2008 14:45:40 -0700
X-Trace: forums-1-dub 1218059140 10.22.241.41 (6 Aug 2008 14:45:40 -0700)
X-Original-Trace: 6 Aug 2008 14:45:40 -0700, 10.22.241.41
Lines: 73
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:87505
Article PK: 416760

Argggg, I cant get it to work. Please, help me! Should I
post it at PowerScript??

I tried this script, but I always get 0 (zero) for any call
I make to it! :(
Please, do you have any ideas??
I've tried PB 8.0.4 Build 1051 and PB 10.2.1 Build 9914

Please, try to help me!!! :(

/* Local External Functions */
Function Long GetDeviceCaps (uLong aul_DC, Long al_Index)
Library "GDI32.DLL"
FUNCTION boolean ClosePrinter( ulong aul_printerhandle )
Library "Winspool.drv"

// PB8
FUNCTION boolean OpenPrinter( string as_printername, ref
ulong aul_printerhandle, ulong aul_printerdefaults) Library
"Winspool.drv" Alias For "OpenPrinterA"
// PB10
FUNCTION boolean OpenPrinter( string as_printername, ref
ulong aul_printerhandle, ulong aul_printerdefaults) Library
"Winspool.drv" Alias For "OpenPrinterA;ansi"

/* My Script */
Constant Long HORZRES = 8
Constant Long VERTRES = 10
Constant Long LOGPIXELSX = 88
Constant Long LOGPIXELSY = 90
Constant Long PHYSICALWIDTH = 110
Constant Long PHYSICALHEIGHT = 111
Constant Long PHYSICALOFFSETX = 112
Constant Long PHYSICALOFFSETY = 113

Long ll_resolution_X, ll_resolution_Y, ll_printorigin_X,
ll_printorigin_Y, ll_pagerect_Left, ll_pagerect_Right,
ll_pagerect_Top, ll_pagerect_Bottom
uLong lul_null, lul_Printer
String ls_PrinterName

SetNull(lul_Null)

// Get Current Printer Name
ls_PrinterName = PrintGetPrinter()
ls_PrinterName = Left(ls_PrinterName, Pos(ls_PrinterName,
"~t") - 1)

// Open Current Printer and get Handle to it
IF OpenPrinter( ls_PrinterName, lul_Printer, lul_Null ) THEN
ll_resolution_X = GetDeviceCaps( lul_Printer, HORZRES )
ll_resolution_Y = GetDeviceCaps( lul_Printer, VERTRES )
ll_printorigin_X = GetDeviceCaps( lul_Printer,
PHYSICALOFFSETX )
ll_printorigin_Y = GetDeviceCaps( lul_Printer,
PHYSICALOFFSETY )
ll_pagerect_Left = 0
ll_pagerect_Right = GetDeviceCaps( lul_Printer,
PHYSICALWIDTH )
ll_pagerect_Top = 0
ll_pagerect_Bottom = GetDeviceCaps( lul_Printer,
PHYSICALHEIGHT )

// Clean Up
ClosePrinter(lul_Printer)
END IF

After I get these values, I'll do my calculations to the get
the printable area, and use it to scale the print job, never
resulting in horizontal pages if the customer's printer has
too large of a non-printable margin.

Thank you!


Jeremy Lakeman Posted on 2008-08-07 02:37:00.0Z
From: Jeremy Lakeman <jeremy.lakeman@gmail.com>
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: DataWindow printing - Margins
Date: Wed, 6 Aug 2008 19:37:00 -0700 (PDT)
Organization: http://groups.google.com
Lines: 88
Message-ID: <3d860e59-b15d-464e-87fb-b4f7ea7a6628@8g2000hse.googlegroups.com>
References: <4899edf5.6c02.1681692777@sybase.com> <489a1b84.6f1b.1681692777@sybase.com>
NNTP-Posting-Host: 203.122.242.105
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1218076620 1827 127.0.0.1 (7 Aug 2008 02:37:00 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 7 Aug 2008 02:37:00 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: 8g2000hse.googlegroups.com; posting-host=203.122.242.105; posting-account=euaBtgoAAAC_vDxfsxmpMKlBxHaHpmRS
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 fly.essential.com.au:3128 (squid/2.5.STABLE8), 1.0 asp.essential.intranet:3128 (squid/2.5.STABLE8)
Path: forums-1-dub!forums-master!newssvr.sybase.com!news-sj-1.sprintlink.net!news-peer1.sprintlink.net!nntp1.phx1.gblx.net!nntp.gblx.net!nntp.gblx.net!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!8g2000hse.googlegroups.com!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:87506
Article PK: 416761


On Aug 7, 6:45 am, Daniel dcferreira [at] attps [.] com [.] br wrote:
> Argggg, I cant get it to work. Please, help me! Should I
> post it at PowerScript??
>
> I tried this script, but I always get 0 (zero) for any call
> I make to it! :(
> Please, do you have any ideas??
> I've tried PB 8.0.4 Build 1051 and PB 10.2.1 Build 9914
>
> Please, try to help me!!! :(
>
> /* Local External Functions */
> Function Long GetDeviceCaps (uLong aul_DC, Long al_Index)
> Library "GDI32.DLL"
> FUNCTION boolean ClosePrinter( ulong aul_printerhandle )
> Library "Winspool.drv"
>
> // PB8
> FUNCTION boolean OpenPrinter( string as_printername, ref
> ulong aul_printerhandle, ulong aul_printerdefaults) Library
> "Winspool.drv" Alias For "OpenPrinterA"
> // PB10
> FUNCTION boolean OpenPrinter( string as_printername, ref
> ulong aul_printerhandle, ulong aul_printerdefaults) Library
> "Winspool.drv" Alias For "OpenPrinterA;ansi"
>
> /* My Script */
> Constant Long HORZRES = 8
> Constant Long VERTRES = 10
> Constant Long LOGPIXELSX = 88
> Constant Long LOGPIXELSY = 90
> Constant Long PHYSICALWIDTH = 110
> Constant Long PHYSICALHEIGHT = 111
> Constant Long PHYSICALOFFSETX = 112
> Constant Long PHYSICALOFFSETY = 113
>
> Long ll_resolution_X, ll_resolution_Y, ll_printorigin_X,
> ll_printorigin_Y, ll_pagerect_Left, ll_pagerect_Right,
> ll_pagerect_Top, ll_pagerect_Bottom
> uLong lul_null, lul_Printer
> String ls_PrinterName
>
> SetNull(lul_Null)
>
> // Get Current Printer Name
> ls_PrinterName = PrintGetPrinter()
> ls_PrinterName = Left(ls_PrinterName, Pos(ls_PrinterName,
> "~t") - 1)
>
> // Open Current Printer and get Handle to it
> IF OpenPrinter( ls_PrinterName, lul_Printer, lul_Null ) THEN
> ll_resolution_X = GetDeviceCaps( lul_Printer, HORZRES )
> ll_resolution_Y = GetDeviceCaps( lul_Printer, VERTRES )
> ll_printorigin_X = GetDeviceCaps( lul_Printer,
> PHYSICALOFFSETX )
> ll_printorigin_Y = GetDeviceCaps( lul_Printer,
> PHYSICALOFFSETY )
> ll_pagerect_Left = 0
> ll_pagerect_Right = GetDeviceCaps( lul_Printer,
> PHYSICALWIDTH )
> ll_pagerect_Top = 0
> ll_pagerect_Bottom = GetDeviceCaps( lul_Printer,
> PHYSICALHEIGHT )
>
> // Clean Up
> ClosePrinter(lul_Printer)
> END IF
>
> After I get these values, I'll do my calculations to the get
> the printable area, and use it to scale the print job, never
> resulting in horizontal pages if the customer's printer has
> too large of a non-printable margin.
>
> Thank you!

Not sure why your API method is failing, but there is a way to find
the printable area on a page using only Powerbuilder code.

Create a simple datawindow with a line object on it.
Insert a detail row and put the datawindow into print preview mode.
Increase the size of the detail row until pagecount() changes.
Increase the position of endx on your line object until
pagecountacross() changes.
For extra credit do a binary search to find when the page counts
change.

voila, you now know the maximum width and height of a printable page
on this printer.


Daniel dcferreira [at] attps [.] com [.] br Posted on 2008-08-07 15:47:22.0Z
Sender: 6f1f.489a1b9a.1804289383@sybase.com
From: Daniel dcferreira [at] attps [.] com [.] br
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: DataWindow printing - Margins
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <489b190a.d6b.1681692777@sybase.com>
References: <3d860e59-b15d-464e-87fb-b4f7ea7a6628@8g2000hse.googlegroups.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 7 Aug 2008 08:47:22 -0700
X-Trace: forums-1-dub 1218124042 10.22.241.41 (7 Aug 2008 08:47:22 -0700)
X-Original-Trace: 7 Aug 2008 08:47:22 -0700, 10.22.241.41
Lines: 65
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:87514
Article PK: 416767

Jeremy, 2 simple questions and a observation for you.

I did what you suggested, thank you!
First the observation: you can't keep the dw on
printpreview, or the computed field (or evaluate) won't
work. This is how it worked for me (both vertical and
horizontal)

ll_Y = Long(ldw_aux.Object.aux1.Width)

Do While True
ll_rows = ldw_aux.InsertRow(0)

ldw_aux.Object.DataWindow.Print.Preview = 'Yes'
ll_VPages = Long(ldw_aux.Describe('Evaluate("PageCount()",
1)'))
ldw_aux.Object.DataWindow.Print.Preview = 'No'

If ll_VPages > 1 Then Exit
Loop

Do While True
ll_Y += 4
ldw_aux.Object.aux1.Width = ll_Y

ldw_aux.Object.DataWindow.Print.Preview = 'Yes'
ll_HPages =
Long(ldw_aux.Describe('Evaluate("PageCountAcross()", 1)'))
ldw_aux.Object.DataWindow.Print.Preview = 'No'

If ll_HPages > 1 Then Exit
Loop

Now the 2 questions:
First, what do I do with the rowcount I have, after reaching
VPage 2? Should I, instead, use the same principle (increase
the height of my object (with the autosize height for the
detail on), instead of a rowcount?

Second, is there a way to get the object that is the
rightmost object of a report? I don't really need this
information, because I can just keep a default report and
keep it's max width and height as a standard for all my
reports, but maybe it's simple to get the information, and
calculate the % scale I have to use for a report, instead of
a global one.

Thank you again!

Thank you!

> Not sure why your API method is failing, but there is a
> way to find the printable area on a page using only
> Powerbuilder code.
>
> Create a simple datawindow with a line object on it.
> Insert a detail row and put the datawindow into print
> preview mode. Increase the size of the detail row until
> pagecount() changes. Increase the position of endx on your
> line object until pagecountacross() changes.
> For extra credit do a binary search to find when the page
> counts change.
>
> voila, you now know the maximum width and height of a
> printable page on this printer.


Jeremy Lakeman Posted on 2008-08-08 01:31:28.0Z
From: Jeremy Lakeman <jeremy.lakeman@gmail.com>
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: DataWindow printing - Margins
Date: Thu, 7 Aug 2008 18:31:28 -0700 (PDT)
Organization: http://groups.google.com
Lines: 104
Message-ID: <16bb7e18-969e-4bed-bdc4-95176e9f4729@k30g2000hse.googlegroups.com>
References: <3d860e59-b15d-464e-87fb-b4f7ea7a6628@8g2000hse.googlegroups.com> <489b190a.d6b.1681692777@sybase.com>
NNTP-Posting-Host: 203.122.242.105
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1218159089 12186 127.0.0.1 (8 Aug 2008 01:31:29 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 8 Aug 2008 01:31:29 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: k30g2000hse.googlegroups.com; posting-host=203.122.242.105; posting-account=euaBtgoAAAC_vDxfsxmpMKlBxHaHpmRS
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 fly.essential.com.au:3128 (squid/2.5.STABLE8), 1.0 asp.essential.intranet:3128 (squid/2.5.STABLE8)
Path: forums-1-dub!forums-master!newssvr.sybase.com!news-sj-1.sprintlink.net!news-peer1.sprintlink.net!nntp1.phx1.gblx.net!nntp.gblx.net!nntp.gblx.net!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!k30g2000hse.googlegroups.com!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:87523
Article PK: 416777


On Aug 8, 12:47 am, Daniel dcferreira [at] attps [.] com [.] br wrote:
> Jeremy, 2 simple questions and a observation for you.
>
> I did what you suggested, thank you!
> First the observation: you can't keep the dw on
> printpreview, or the computed field (or evaluate) won't
> work. This is how it worked for me (both vertical and
> horizontal)
>
> ll_Y = Long(ldw_aux.Object.aux1.Width)
>
> Do While True
>         ll_rows = ldw_aux.InsertRow(0)
>
>         ldw_aux.Object.DataWindow.Print.Preview = 'Yes'
>         ll_VPages = Long(ldw_aux.Describe('Evaluate("PageCount()",
> 1)'))
>         ldw_aux.Object.DataWindow.Print.Preview = 'No'
>
>         If ll_VPages > 1 Then Exit
> Loop
>
> Do While True
>         ll_Y += 4
>         ldw_aux.Object.aux1.Width = ll_Y
>
>         ldw_aux.Object.DataWindow.Print.Preview = 'Yes'
>         ll_HPages =
> Long(ldw_aux.Describe('Evaluate("PageCountAcross()", 1)'))
>         ldw_aux.Object.DataWindow.Print.Preview = 'No'
>
>         If ll_HPages > 1 Then Exit
> Loop
>
> Now the 2 questions:
> First, what do I do with the rowcount I have, after reaching
> VPage 2? Should I, instead, use the same principle (increase
> the height of my object (with the autosize height for the
> detail on), instead of a rowcount?
>
> Second, is there a way to get the object that is the
> rightmost object of a report? I don't really need this
> information, because I can just keep a default report and
> keep it's max width and height as a standard for all my
> reports, but maybe it's simple to  get the information, and
> calculate the % scale I have to use for a report, instead of
> a global one.
>
> Thank you again!
>
> Thank you!
>
> > Not sure why your API method is failing, but there is a
> > way to find the printable area on a page using only
> > Powerbuilder code.
>
> > Create a simple datawindow with a line object on it.
> > Insert a detail row and put the datawindow into print
> > preview mode. Increase the size of the detail row until
> > pagecount() changes. Increase the position of endx on your
> > line object until pagecountacross() changes.
> > For extra credit do a binary search to find when the page
> > counts change.
>
> > voila, you now know the maximum width and height of a
> > printable page on this printer.

Instead of inserting multiple rows, just insert one row and call
SetDetailHeight.

You can get a list of all objects in a datawindow from;
ls_names=dw_1.object.datawindow.objects
Which returns a tab-delimited list of all object names. From there you
can describe all of their positions and widths to find the maximum
extent of the visible objects.

Also instead of gradually incrementing which could take a while..

long ll_min, ll_max, ll_test

ll_test=<some arbitrary value on the first page>
ll_min=ll_test

do while true
ll_test*=2
...
if pagecount>1 then exit
ll_min=ll_test
loop

ll_max=ll_test

do while true
ll_test=truncate((ll_max - ll_min)/2.0,0)
if ll_test = ll_min then exit
..
if pagecount>1 then
ll_max=ll_test
else
ll_min=ll_test
end if
loop


Daniel dcferreira [at] attps [.] com [.] br Posted on 2008-08-07 12:57:59.0Z
Sender: 6f1f.489a1b9a.1804289383@sybase.com
From: Daniel dcferreira [at] attps [.] com [.] br
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: DataWindow printing - Margins
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <489af157.852.1681692777@sybase.com>
References: <3d860e59-b15d-464e-87fb-b4f7ea7a6628@8g2000hse.googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 7 Aug 2008 05:57:59 -0700
X-Trace: forums-1-dub 1218113879 10.22.241.41 (7 Aug 2008 05:57:59 -0700)
X-Original-Trace: 7 Aug 2008 05:57:59 -0700, 10.22.241.41
Lines: 96
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:87511
Article PK: 416768

Bro, thank you for the "technical resource" :-)
I´ll try to implement this asap!
TY!!

> On Aug 7, 6:45 am, Daniel dcferreira [at] attps [.] com
> > [.] br wrote: Argggg, I cant get it to work. Please,
> > help me! Should I post it at PowerScript??
> >
> > I tried this script, but I always get 0 (zero) for any
> > call I make to it! :(
> > Please, do you have any ideas??
> > I've tried PB 8.0.4 Build 1051 and PB 10.2.1 Build 9914
> >
> > Please, try to help me!!! :(
> >
> > /* Local External Functions */
> > Function Long GetDeviceCaps (uLong aul_DC, Long
> > al_Index) Library "GDI32.DLL"
> > FUNCTION boolean ClosePrinter( ulong aul_printerhandle )
> > Library "Winspool.drv"
> >
> > // PB8
> > FUNCTION boolean OpenPrinter( string as_printername, ref
> > ulong aul_printerhandle, ulong aul_printerdefaults)
> > Library "Winspool.drv" Alias For "OpenPrinterA"
> > // PB10
> > FUNCTION boolean OpenPrinter( string as_printername, ref
> > ulong aul_printerhandle, ulong aul_printerdefaults)
> > Library "Winspool.drv" Alias For "OpenPrinterA;ansi"
> >
> > /* My Script */
> > Constant Long HORZRES = 8
> > Constant Long VERTRES = 10
> > Constant Long LOGPIXELSX = 88
> > Constant Long LOGPIXELSY = 90
> > Constant Long PHYSICALWIDTH = 110
> > Constant Long PHYSICALHEIGHT = 111
> > Constant Long PHYSICALOFFSETX = 112
> > Constant Long PHYSICALOFFSETY = 113
> >
> > Long ll_resolution_X, ll_resolution_Y, ll_printorigin_X,
> > ll_printorigin_Y, ll_pagerect_Left, ll_pagerect_Right,
> > ll_pagerect_Top, ll_pagerect_Bottom
> > uLong lul_null, lul_Printer
> > String ls_PrinterName
> >
> > SetNull(lul_Null)
> >
> > // Get Current Printer Name
> > ls_PrinterName = PrintGetPrinter()
> > ls_PrinterName = Left(ls_PrinterName,
Pos(ls_PrinterName
> > , "~t") - 1)
> >
> > // Open Current Printer and get Handle to it
> > IF OpenPrinter( ls_PrinterName, lul_Printer, lul_Null )
> > THEN ll_resolution_X = GetDeviceCaps( lul_Printer,
> > HORZRES ) ll_resolution_Y = GetDeviceCaps(
lul_Printer,
> > VERTRES ) ll_printorigin_X = GetDeviceCaps(
lul_Printer,
> > PHYSICALOFFSETX )
> > ll_printorigin_Y = GetDeviceCaps( lul_Printer,
> > PHYSICALOFFSETY )
> > ll_pagerect_Left = 0
> > ll_pagerect_Right = GetDeviceCaps( lul_Printer,
> > PHYSICALWIDTH )
> > ll_pagerect_Top = 0
> > ll_pagerect_Bottom = GetDeviceCaps( lul_Printer,
> > PHYSICALHEIGHT )
> >
> > // Clean Up
> > ClosePrinter(lul_Printer)
> > END IF
> >
> > After I get these values, I'll do my calculations to the
> > get the printable area, and use it to scale the print
> > job, never resulting in horizontal pages if the
> > customer's printer has too large of a non-printable
> margin. >
> > Thank you!
>
> Not sure why your API method is failing, but there is a
> way to find the printable area on a page using only
> Powerbuilder code.
>
> Create a simple datawindow with a line object on it.
> Insert a detail row and put the datawindow into print
> preview mode. Increase the size of the detail row until
> pagecount() changes. Increase the position of endx on your
> line object until pagecountacross() changes.
> For extra credit do a binary search to find when the page
> counts change.
>
> voila, you now know the maximum width and height of a
> printable page on this printer.