FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) Printing routine
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Printing routine
Posted: Tue Dec 13, 2016 10:37 PM
Hello Antonio,

Can you please revise the printing routine. If I compile testprn3 I get an error.
Code (fw): Select all Collapse
Undefined symbols for architecture x86_64:
  "_HB_FUN_PRNINFOPAGSETBOTTOMMARGIN", referenced from:
      _symbols_table in libfive.a(printer.o)

Maybe this must be PRNINFOPAGESETBOTTOMMARGIN?

And where can I find more info about the FUNCTION PrinterSelect() in sample testprn2?
Kind regards,



René Koot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Printing routine
Posted: Wed Dec 14, 2016 11:46 AM

René,

Already fixed.

I have emailed you the FiveMac modified libs

many thanks for your feedback :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Printing routine
Posted: Wed Dec 14, 2016 06:18 PM

Hello Antonio,

Again thanks for the very quick reply. Now the sample works perfect.

Almost ready with the first version of my program. Hope to distribute it next month.

Kind regards,



René Koot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Printing routine
Posted: Thu Dec 15, 2016 07:44 AM

excellent :-)

congratulations!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Printing routine
Posted: Fri Dec 16, 2016 05:00 PM
Hello Antonio,

I am able to print a lot of information now. You can se the result at the next link:
http://www.plantenkennis.com/downloads/Print_Plantenkennis.pdf
For the part on the leftside of the picture I use this code:
Code (fw): Select all Collapse
    FOR n = 1 TO LEN(aGegevens)
        IF LEN(ALLTRIM(aGegevens[n,1])) > 0
            @ nRow, nCol SAY oSay PROMPT aGegevens[n,1] + ':' OF oPrn SIZE 105, 35
                osay:Setfont("Arial",11 )
        ENDIF
        @ nRow, nCol+106 SAY oSay PROMPT aGegevens[n,2] OF oPrn SIZE 150, 35
            osay:Setfont("Arial",11 )
            nRow := nRow + 35
    NEXT

But some texts don't need to be on two lines. ìf you see 'planttype' and 'Vaste Plant' this is just one line, but I use two lines. Is there a wy to check how wide the text is, so I can play with the line spaces.

the same is with the 'Aantekeningen' and 'Snoei' The 'Aantekeningen' is a richtext and the 'Snoei' is just a long text The linespace is different. And, can I calculate how much lines there are needed to print all text (it is in a memofield)

Code (fw): Select all Collapse
    IF LEN(ALLTRIM(cAanteken)) > 0
        @ nRow, nCol SAY oSay PROMPT 'Aantekeningen' OF oPrn SIZE 150, 20
            osay:Setfont("Arial Black",12 )
            nRow := nRow + 20
    
        @ nRow, nCol  LINE HORIZONTAL SIZE oPrn:pageWidth()- 20 OF oPrn
    
        @ nRow, nCol GET oGetRichText VAR cText MEMO OF oPrn SIZE oPrn:pageWidth()- 40, 100
            oGetRichText:SetRichText(.t.)
            oGetRichText:SetImportGraf(.t.)
            oGetRichText:SetUndo(.t.)      
            cText := cAanteken
            oGetRichText:SetAttributedString(cText)
            oGetRichText:GoTop()
        nRow := nRow + 100
    ENDIF
    
    IF LEN(ALLTRIM(cSnoei)) > 0
        @ nRow, nCol SAY oSay PROMPT 'Snoei' OF oPrn SIZE 150, 20
            osay:Setfont("Arial Black",12 )
            nRow := nRow + 20
    
        @ nRow, nCol  LINE HORIZONTAL SIZE oPrn:pageWidth()- 20 OF oPrn
    
        @ nRow, nCol SAY oSay PROMPT cSnoei OF oPrn SIZE 500, 100
            osay:Setfont("Arial",12 )
    ENDIF
Kind regards,



René Koot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Printing routine
Posted: Fri Dec 16, 2016 06:26 PM

René,

> But some texts don't need to be on two lines

If you increase the width of the SAY control then the text should fit in just one line.

Do you mean that ?

> can I calculate how much lines there are needed to print all text

You may use Harbour MLCount() to know how many lines the text has

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Printing routine
Posted: Sat Dec 17, 2016 04:13 PM

Hello Antonio,

What I mean is: can I calculate how wide a text string is when printed or showed.
Example:
'this is a string' can fit on one line in my example
'this is a very long string that does jot fit on one line' does not fit on one line so I must increase the height of the say to show itmon two lines.
The width of a text is not only depending on the numbers of characters, but also on the fonttype and fontsize. So, is there a function to calculate the widht of a string with a given fontname and size.

In minigui we have such a function, but it is depending on HbPrinter.

Kind regards,



René Koot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Printing routine
Posted: Sun Dec 18, 2016 10:17 AM
René,

It seems as here we have what we need:
http://stackoverflow.com/questions/1324379/how-to-calculate-the-width-of-a-text-string-of-a-specific-font-and-font-size

I am going to implement it in FiveMac
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Printing routine
Posted: Sun Dec 18, 2016 10:46 AM

Hello Antonio,

Yes, it looks like that is what I ment. Thanks for looking in to this.

Kind regards,



René Koot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Printing routine
Posted: Sun Dec 18, 2016 04:10 PM
René,

I have finally implemented it this way:
Code (fw): Select all Collapse
HB_FUNC( TXTGETWIDTH )
{
   NSString * text = hb_NSSTRING_par( 1 );
   NSString * name = hb_NSSTRING_par( 2 );
   NSFont * font = [ NSFont fontWithName: name size:  hb_parnl( 3 ) ];
   CGSize frameSize = CGSizeMake( 300, 50 );

   CGRect idealFrame = [ text boundingRectWithSize: frameSize
                         options: NSStringDrawingUsesLineFragmentOrigin
                         attributes: @{ NSFontAttributeName: font }
                         context: nil ];

   hb_retnl( idealFrame.size.width );
}


Example of use:
TxtGetWidth( "the text", "Arial", 20 ) --> nWidth

I am sending you the new FiveMac libs.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Printing routine
Posted: Sun Dec 18, 2016 08:25 PM

Helo Antonio,

Thanks for this (very quick :D ) solution. I think it is just what I need. I will test it tomorrow.

Kind regards,



René Koot
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Printing routine
Posted: Mon Dec 19, 2016 07:27 PM

Hello Antonio,

Thank you, this function does exactly what I want. It is a great programming language.

Kind regards,



René Koot

Continue the discussion