Page 1 of 1
Printing routine
Posted: Tue Dec 13, 2016 10:37 pm
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 PRNINFOPAG
ESETBOTTOMMARGIN?
And where can I find more info about the FUNCTION PrinterSelect() in sample testprn2?
Re: Printing routine
Posted: Wed Dec 14, 2016 11:46 am
by Antonio Linares
René,
Already fixed.
I have emailed you the FiveMac modified libs
many thanks for your feedback
Re: Printing routine
Posted: Wed Dec 14, 2016 6:18 pm
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.
Re: Printing routine
Posted: Thu Dec 15, 2016 7:44 am
by Antonio Linares
excellent
congratulations!
Re: Printing routine
Posted: Fri Dec 16, 2016 5:00 pm
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
Re: Printing routine
Posted: Fri Dec 16, 2016 6:26 pm
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
Re: Printing routine
Posted: Sat Dec 17, 2016 4:13 pm
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.
Re: Printing routine
Posted: Sun Dec 18, 2016 10:17 am
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
Re: Printing routine
Posted: Sun Dec 18, 2016 10:46 am
by plantenkennis
Hello Antonio,
Yes, it looks like that is what I ment. Thanks for looking in to this.
Re: Printing routine
Posted: Sun Dec 18, 2016 4:10 pm
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.
Re: Printing routine
Posted: Sun Dec 18, 2016 8:25 pm
by plantenkennis
Helo Antonio,
Thanks for this (very quick
) solution. I think it is just what I need. I will test it tomorrow.
Re: Printing routine
Posted: Mon Dec 19, 2016 7:27 pm
by plantenkennis
Hello Antonio,
Thank you, this function does exactly what I want. It is a great programming language.