FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) printing on portrait or landscape paper
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
printing on portrait or landscape paper
Posted: Tue May 28, 2019 06: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 (fw): Select all Collapse
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
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: printing on portrait or landscape paper
Posted: Wed May 29, 2019 12:46 PM
Change method setpagOrinetation () to this
Code (fw): Select all Collapse
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 (fw): Select all Collapse
 METHOD GetPagOrientation() INLINE PrnInfoPagGetOrientation( ::hPrnInfo )


Code (fw): Select all Collapse
HB_FUNC( PRNINFOPAGGETORIENTATION)
{
  NSPrintInfo * pi = ( NSPrintInfo *   ) hb_parnl( 1 );
  NSInteger nOrientation = pi.orientation ;
  hb_retnl( ( HB_LONG ) nOrientation );
}
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: printing on portrait or landscape paper
Posted: Wed May 29, 2019 06: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
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: printing on portrait or landscape paper
Posted: Wed May 29, 2019 06: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
----
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: printing on portrait or landscape paper
Posted: Thu May 30, 2019 08: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
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: printing on portrait or landscape paper
Posted: Fri May 31, 2019 06: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 (fw): Select all Collapse
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.
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: printing on portrait or landscape paper
Posted: 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
Posts: 1
Joined: Mon Apr 13, 2020 02:48 PM
Re: printing on portrait or landscape paper
Posted: Mon Apr 13, 2020 05:08 PM

good post!

Continue the discussion