printing on portrait or landscape paper

printing on portrait or landscape paper

Postby plantenkennis » Tue May 28, 2019 6:16 pm

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  Expand view

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
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: printing on portrait or landscape paper

Postby mastintin » Wed May 29, 2019 12:46 pm

Change method setpagOrinetation () to this
Code: Select all  Expand view

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  Expand view

 METHOD GetPagOrientation() INLINE PrnInfoPagGetOrientation( ::hPrnInfo )
 


Code: Select all  Expand view

HB_FUNC( PRNINFOPAGGETORIENTATION)
{
  NSPrintInfo * pi = ( NSPrintInfo *   ) hb_parnl( 1 );
  NSInteger nOrientation = pi.orientation ;
  hb_retnl( ( HB_LONG ) nOrientation );
}
 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: printing on portrait or landscape paper

Postby plantenkennis » Wed May 29, 2019 6:00 pm

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
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: printing on portrait or landscape paper

Postby mastintin » Wed May 29, 2019 6:19 pm

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
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: printing on portrait or landscape paper

Postby plantenkennis » Thu May 30, 2019 8:58 pm

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
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: printing on portrait or landscape paper

Postby mastintin » Fri May 31, 2019 6:39 am

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  Expand view


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
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: printing on portrait or landscape paper

Postby plantenkennis » Fri May 31, 2019 12:03 pm

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
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: printing on portrait or landscape paper

Postby omarlopez » Mon Apr 13, 2020 5:08 pm

good post!
omarlopez
 
Posts: 1
Joined: Mon Apr 13, 2020 2:48 pm
Location: santiago / chile


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 14 guests