printing on portrait or landscape paper

Post Reply
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

printing on portrait or landscape paper

Post by plantenkennis »

Hello,

While printing we can set the oriantation of the paper to portrait or landscape. But the number of rows we can print stay the same, Look at this sample. As you change oPrn:SetPagOrientation(0) to oPrn:SetPagOrientation(1) there are still 37 lines on the paper, but the spacing between the lines is smaller. Also the code to print the pagenumber does not work.

Code: Select all

FUNCTION RK_TestPrint()

LOCAL nPage := 1
LOCAL nCol := 28    && the column we start printing
LOCAL nRow := 1 && the row we start printing
LOCAL cText := ''
LOCAL oPrn:=TPrinter():new(0,0,0,0)

oPrn:SetLeftMargin(0)
oPrn:SetRightMargin(0)
oPrn:SetTopMargin(0)
oPrn:SetbottomMargin(0)
oPrn:setPaperName("A4")
*oPrn:AutoPage(.T.)
oPrn:SetPagOrientation(0)

oPrn:StartPage()

FOR n = 1 TO 100
    cText := 'This is line: ' + ALLTRIM(STR(nRow))

    @ nRow, 28 SAY oSay PROMPT cText OF oPrn PAGINED SIZE 300, 20 
            oSay:Setfont(Arial,12 )
    nRow++

    IF nRow > oPrn:LastRow()-2
        @ oPrn:LastRow(), 450 SAY oSay PROMPT 'page ' + ALLTRIM(STR(nPage)) OF oPrn PAGINED SIZE 300, 20 
            oSay:Setfont(Arial,12 )
        nPage++
        nRow := 1
        oPrn:EndPage()
        oPrn:StartPage()
    ENDIF

NEXT


oPrn:EndPage()

oPrn:run()

RETURN NIL
 
Can we change the number of lines that are printed on the paper OR change the spacing between the lines.
Kind regards,

René Koot
User avatar
mastintin
Posts: 1502
Joined: Thu May 27, 2010 2:06 pm

Re: printing on portrait or landscape paper

Post by mastintin »

Change method setpagOrinetation () to this

Code: Select all

METHOD SetPagOrientation( nOrientation ) CLASS TPrinter

    PrnInfoPagSetOrientation( ::hPrnInfo, nOrientation )
    if nOrientation == 0
       ::nRowsPerPage := 40
    elseif nOrientation == 1
       ::nRowsPerPage := 20
    endif

return nil

 
See if nRowperpage is good in 20 for you.

And new method ...

Code: Select all

 METHOD GetPagOrientation() INLINE PrnInfoPagGetOrientation( ::hPrnInfo )
 

Code: Select all

HB_FUNC( PRNINFOPAGGETORIENTATION)
{
  NSPrintInfo * pi = ( NSPrintInfo *   ) hb_parnl( 1 );
  NSInteger nOrientation = pi.orientation ;
  hb_retnl( ( HB_LONG ) nOrientation );
}
 
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: printing on portrait or landscape paper

Post by plantenkennis »

Hello Manuel,

This looks good I think. But how if we print in a large fontsize? Is it possible to set the nSetrowPerPage just like set PageOrientation?
Kind regards,

René Koot
User avatar
mastintin
Posts: 1502
Joined: Thu May 27, 2010 2:06 pm

Re: printing on portrait or landscape paper

Post by mastintin »

plantenkennis wrote:Hello Manuel,

This looks good I think. But how if we print in a large fontsize? Is it possible to set the nSetrowPerPage just like set PageOrientation?
Yes of course.
You can adjust the number of lines you want both horizontally and vertically.
LastRow will be ::nRowsPerPage - 1 .

...
oPrn:SetPagOrientation(0)
oPrn:nRowsPerPage := 33
----
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: printing on portrait or landscape paper

Post by plantenkennis »

Hello Manuel,

That looks perfect. I assume I need a new lib for this function? I dod not see one on BitBucket...
Kind regards,

René Koot
User avatar
mastintin
Posts: 1502
Joined: Thu May 27, 2010 2:06 pm

Re: printing on portrait or landscape paper

Post by mastintin »

Right now, I have problems with bitbucket ,I have uploaded the changes to repository but libs not upload .
for the moment you can use it directly on your code.

Code: Select all


local nOrinetation := 0
.....
oPrn:SetTopMargin(0)
oPrn:SetbottomMargin(0)
oPrn:setPaperName("A4")
*oPrn:AutoPage(.T.)

nOrientation := 1 
oPrn:SetPagOrientation( nOrientation)
  if nOrientation == 0
       oPrn:nRowsPerPage := 40  // your rows
    elseif nOrientation == 1
       oprn:nRowsPerPage := 20 // your rows 
    endif
...........

 
I'm sorry for the problems.
regards.

//-------------- edit --------------------

New libs is uploaded , make a copy of the previous ones and check that you do not create problems.
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: printing on portrait or landscape paper

Post by plantenkennis »

Hello Manuel,

Thank you very much, with the new libs it works perfect. :D

Another question: Can we also set the papersize to A5 or A3 (portrait and landscape)?
Kind regards,

René Koot
omarlopez
Posts: 1
Joined: Mon Apr 13, 2020 2:48 pm
Location: santiago / chile
Contact:

Re: printing on portrait or landscape paper

Post by omarlopez »

good post!
Post Reply