Print in columns
Print in columns
I have just started using PB with a small data base. How do you print data in aligned columns with proportional fonts? The columns line up fine with a fixed font.
Re: Print in columns
How do you do this at the moment?
Do you use StartVectorDrawing(PrinterVectorOutput()) and DrawVectorText()?
Do you use StartVectorDrawing(PrinterVectorOutput()) and DrawVectorText()?
Re: Print in columns
As infratec pointed out
Code: Select all
If PrintRequester()
If StartPrinting("PureBasic Test")
LoadFont(0, "Arial", 10)
If StartVectorDrawing(PrinterVectorOutput())
VectorFont(FontID(0), 12)
VectorSourceColor(RGBA(0, 0, 0, 255))
MovePathCursor(10, 25)
AddPathText("Column #1")
FillPath()
VectorSourceColor(RGBA(255, 0, 0, 255))
MovePathCursor(150, 25)
AddPathText("Column #2")
FillPath()
VectorSourceColor(RGBA(0, 255,255, 255))
MovePathCursor(300, 25)
AddPathText("Column #3")
FillPath()
VectorFont(FontID(0), 6)
VectorSourceColor(RGBA(0, 0, 0, 255))
MovePathCursor(10, 50)
AddPathText("Column #2-1")
FillPath()
VectorSourceColor(RGBA(255, 0, 0, 255))
MovePathCursor(150, 50)
AddPathText("Column #2-2")
FillPath()
VectorSourceColor(RGBA(0, 0,255, 255))
MovePathCursor(300, 50)
AddPathText("Column #2-3")
FillPath()
StopVectorDrawing()
EndIf
StopPrinting()
EndIf
EndIf
Egypt my love
Re: Print in columns
Use Rset() to right justify column entries with Chr($2007) for spacing. The code would be something like this.
Rset(string$,length,chr($2007))
Look up spacing of unicode character to see why this works.
Unicode character 2007 is known a figure space. It is a space character that is as wide as fixed-width digits. Usually used when typesetting vertically aligned numbers.
Below is a sample of code I used to print out a matrix. Note use of different space character for minus sign. Hope this helps.
Rset(string$,length,chr($2007))
Look up spacing of unicode character to see why this works.
Unicode character 2007 is known a figure space. It is a space character that is as wide as fixed-width digits. Usually used when typesetting vertically aligned numbers.
Below is a sample of code I used to print out a matrix. Note use of different space character for minus sign. Hope this helps.
Code: Select all
ns1$=chr($2007)
For i=1 To ncmps ;For each row of B-Matrix (note B is a square matrix)
p$=RSet(Str(i),6,ns1$)
For k=1 To ncmps ;For each col of B-Matrix
a.f=Bmatrix(i,k)*10000.0
If a.f<0 ;use slightly different spacing due to minus sign
p$=p$+#CRLF$+RSet(StrF(Bmatrix(i,k)*10000.0,3),6,ns1$)
Else
p$=p$+#CRLF$+Chr($2004)+RSet(StrF(Bmatrix(i,k)*10000.0,3),5,ns1$)
EndIf
Next
AddGadgetItem(#Table1,-1,p$)
If Mod(i,5)=0
SetGadgetItemColor(#Table1,i-1,#PB_Gadget_BackColor,ColorBack3,#PB_All)
EndIf
Next
- Thorsten1867
- Addict
- Posts: 1366
- Joined: Wed Aug 24, 2005 4:02 pm
- Location: Germany
Re: Print in columns
I create a PDF (pbPDFModule.pbi) for such things.
Translated with http://www.DeepL.com/Translator
Download of PureBasic - Modules
Download of PureBasic - Programs
[Windows 11 x64] [PB V5.7x]
Download of PureBasic - Modules
Download of PureBasic - Programs
[Windows 11 x64] [PB V5.7x]
Re: Print in columns
Too many alternatives
- Create ListiconGadget()
- Populate the ListIcon()
- Save it as Image
- Print the Image later
But still the Vector lib. is the best
- Create ListiconGadget()
- Populate the ListIcon()
- Save it as Image
- Print the Image later
But still the Vector lib. is the best
Egypt my love
Re: Print in columns
If there is a lot of text, prefer DrawVectorText() rather than AddPathText()
(See why on Remarks on help on AddPathText()). Same code works.
(See why on Remarks on help on AddPathText()). Same code works.
Re: Print in columns
Thank you all for the suggestions. I will try when I get home from work.
I am currently basing my code on the print sample that comes with the PB distribution.
I am currently basing my code on the print sample that comes with the PB distribution.
Re: Print in columns
I implemented the solution suggested by RASHAD and it works quite nicely. It took a little experimenting to get the spacing correct, but it was not too hard. After reading the differences between the two functions, I made the change suggested by Marc56us to use DrawVectorText() instead of AddPathText().
Thank you all for your help and quick replies.
Thank you all for your help and quick replies.
Re: Print in columns
With the vector lib you can change the units to mm or inch.
Maybe that's easier.
https://www.purebasic.com/documentation ... runit.html
Maybe that's easier.
https://www.purebasic.com/documentation ... runit.html