Help with Carbonized printing

Hi,
I was creating app with xojo 2014 r.4.3 and mr. alex restrepo plugin to print the listbox.
It working nicely, the text shown very clear.

Now I was trying to open the project with xojo 2021.r1.1, the text is printed blurry.
is there any setting that I have to be put in?

thanks
arief

You have to:
a. rewrite the code by yourself,
b. share Alex’s code
c. Explain what Alex’s code is doing (logic)…

Without these, how can we guess something useful ?

I think that @Jean-Yves_Pochez may have some of the latest versions, @Axel_Schneider seemed maintaining it, but… long time no see… and his website is gone http://www.axel-erfurt.de/apps/ListboxPrinter.zip

Printing needs to pay attention to printer resolution and adapt to it. Your code probably is using 72ppi.

all axel xojo project are in his dropbox here

look for LBAxel2015.

2 Likes

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

Read this page:

https://documentation.xojo.com/topics/printing/sending_data_to_the_printer.html#topics-printing-sending-data-to-the-printer-desktop-printing

in the early code, look about Resolution (vertical and horizontal).

Your code above does not set any, so IMHO, your printing is done at nominal OS resoluton (72 dpi for MacOS or 96 dpi for WIndows).

hi,

Thanks for the info. Will do some test .

just a question,

The code is only problem with dot matrix printer, with inkjet or laser jet printer its worked normally.
how to find out which Printer resolution needed.? is it depend to the type of the printer.?

I am using Epson LQ310 Dot Matrix 24 pin,it is mentioned on web that the DPI is 360 x 360.
Do I have to set into that size ?

thanks
regards,
arief

I do not print to paper since… so long I do not recall.

Read here:
https://documentation.xojo.com/api/printing/printersetup.html#printersetup-horizontalresolution

There are some code you can run to understand (I think).

same for vertical resolution. But reading one let you understand how to use.