Hi,
I have download and tested, its worked, but I am forgot to info that I put a canvas also there to add some additional text needed. I think its a printer resolution problem, but I dont know how to define it on a canvas.
Here’s the code,
dim setup as new printerSetup
dim totalWidth as integer
dim row, column as integer
dim columnScale as single
dim sx, sy, w, h, maxH, xs(), i as integer
self.source=source
setup=new printerSetup
if setup.PageSetupDialog then
dim printer as Graphics=openprinterDialog(setup)
if printer<>nil then
if fitWidth then
//find total width
for row=0 to source.columncount-1
totalWidth=totalWidth+source.column(row).widthActual
next
columnScale=setup.width/totalWidth
else
columnScale=1
end if
sx=0
sy = self.printHeaders(0,printer,columnscale,xs)+3
for row=0 to source.listcount-1
for column=0 to source.columncount-1
w=source.column(column).widthActual*columnScale
self.printCell(row,column,printer,xs(column),sy,w,h)
if h>maxH then maxH=h
next
sx=0
sy=sy+maxH+2
maxH=0
if sy+printer.textascent>setup.height then
for i=0 to ubound(xs)
printer.foreColor=lineColor
'printer.drawline xs(i),headerHeight,xs(i),printer.height
printer.foreColor=textcolor
next
printer.nextPage
sy=self.printHeaders(0,printer,columnscale,xs)+3
end if
next
for i=0 to ubound(xs)
printer.foreColor=linecolor
'printer.drawline xs(i),source.Width,xs(i),source.height 'ilangkan garis
printer.foreColor=textcolor
next
end if
end if
and the canvas code,
dim d as new date
g.TextSize=8
g.DrawString "Surat Jalan dicetak : "+d.ShortDate, g.Width - g.StringWidth("Surat Jalan dicetak : "+d.ShortDate) - 5, 15 - 10
g.TextSize=7
g.DrawString " Sales, Finance, Store, Kurir, Penerima",0,613'683
g.DrawString "( ) ( ) ( ) ( ) ( ) ",0,650'720
g.DrawString " Tgl. Diterima : ",0,660'720
g.drawRect 260,675,7,7 '745
g.DrawString "Surat CK6",270,680 '750
g.drawRect 130,675,7,7 '745
g.DrawString "Invoice Asli",140,680'750
g.drawRect 190,675,7,7 '745
g.DrawString "Kwitansi",200,680'750
g.drawRect 120,655,200,30 '725
g.DrawString "Lampiran :",130,665'735
g.TextSize=7
g.DrawString " * Lembar Putih = Customer/Shop | *Lembar Merah = Finance | *Lembar Kuning = Inventory",0,700'613
if Window1.chkrkma.Value then
g.Bold=true
g.TextSize=20
g.DrawString "PT. ABC" ,65, 50
end if
if Window1.chktusa.Value then
g.Bold=true
g.TextSize=20
g.DrawString "PT. 123" ,65, 50
end if
if Window1.chkmbpl.Value then
g.Bold=true
g.TextSize=20
g.DrawString "PT. XXX" ,65, 50
end if
if Window1.chkrkma.Value=false and Window1.chktusa.Value=false and Window1.chkmbpl.Value=false then
g.drawPicture logo,180,0
end if
g.Bold=true
g.TextSize=20
G.Bold = false
g.TextSize=10
g.DrawString "Jl. Padasaluyu Utara II No. 3 Kel. Isola Kec. Sukasari Kota Bandung 40154" ,57, 90 ' left , top
g.DrawString "022-201055 FAX : 022-2014 47 Email : sales-ws@gmail.com" ,56, 100 ' left , top
g.Bold=true
g.DrawString "_____________________________________________________________________________________________________________" ,5,105 ' left , top
G.Bold = false
g.TextSize=10
if Window1.r4.Value then
g.DrawString "Retur ke : "+ Window1.cSupplier.Text ,10, 120 ' left , top
g.DrawString "Date : "+ Window1.tgl.text ,10, 140 ' left , top
else
g.DrawString "Customer : "+ Window1.l_cust.text ,10, 120 ' left , top
g.DrawString "SO Number : "+ Window1.t_so_number.text ,10, 130 ' left , top
g.DrawString "Request Date : "+ Window1.l_date.text ,10, 140 ' left , top
g.DrawString "Term of Payment : "+ Window1.t_term.text +" Hari",10, 150 ' left , top
end if
g.TextSize=16
g.Bold=true
g.DrawString "SURAT JALAN" ,g.Width - g.StringWidth("SURAT JALAN") *2.5, 180 ' left , top
g.TextSize=12
g.Bold=false
any helps?
thanks
arief