Printing routine

Printing routine

Postby plantenkennis » 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: Select all  Expand view
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
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: Printing routine

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

Re: Printing routine

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

Re: Printing routine

Postby Antonio Linares » Thu Dec 15, 2016 7:44 am

excellent :-)

congratulations!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41206
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Printing routine

Postby plantenkennis » Fri Dec 16, 2016 5: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: Select all  Expand view
    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  Expand view
    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
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: Printing routine

Postby Antonio Linares » Fri Dec 16, 2016 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41206
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Printing routine

Postby plantenkennis » Sat Dec 17, 2016 4: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
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: Printing routine

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

Re: Printing routine

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

Re: Printing routine

Postby Antonio Linares » Sun Dec 18, 2016 4:10 pm

René,

I have finally implemented it this way:
Code: Select all  Expand view
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
Antonio Linares
Site Admin
 
Posts: 41206
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Printing routine

Postby plantenkennis » Sun Dec 18, 2016 8: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
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: Printing routine

Postby plantenkennis » Mon Dec 19, 2016 7:27 pm

Hello Antonio,

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

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 2 guests