Printing routine

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

Printing routine

Post by plantenkennis »

Hello Antonio,

Can you please revise the printing routine. If I compile testprn3 I get an error.

Code: Select all

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Printing routine

Post by Antonio Linares »

René,

Already fixed.

I have emailed you the FiveMac modified libs

many thanks for your feedback :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: Printing routine

Post by plantenkennis »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Printing routine

Post by Antonio Linares »

excellent :-)

congratulations!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: Printing routine

Post by plantenkennis »

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/ ... kennis.pdf
For the part on the leftside of the picture I use this code:

Code: Select all

    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: Select all

    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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Printing routine

Post by Antonio Linares »

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

Re: Printing routine

Post by plantenkennis »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Printing routine

Post by Antonio Linares »

René,

It seems as here we have what we need:
http://stackoverflow.com/questions/1324 ... -font-size

I am going to implement it in FiveMac
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: Printing routine

Post by plantenkennis »

Hello Antonio,

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

René Koot
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Printing routine

Post by Antonio Linares »

René,

I have finally implemented it this way:

Code: Select all

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

Re: Printing routine

Post by plantenkennis »

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

Re: Printing routine

Post by plantenkennis »

Hello Antonio,

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

René Koot
Post Reply