[Gambas-user] print resolution issues

Paul Horechuk horechuk at ...981...
Fri Oct 10 21:11:04 CEST 2014


Aparantly, I am trying to draw a the pixel level as I want to precisely 
position the contents of each label. I open the printer as a drawng 
area, as in:

Public Sub MyPrinter_Begin()
' Only 1 page for now
   MyPrinter.Count = 1
   MyPrinter.Resolution = 100  ' Set to 100 works great. 300 shrinks the 
print coordinates to 1/3
   MyPrinter.FullPage = True
End

Paint.Begin(MyPrinter)
   'Initialize the new DrawingArea to the papersize
   'This print routine is designed for Avery #5371
     dArea.Width = myPrinter.PaperWidth
     dArea.Height = myPrinter.PaperHeight
'   The size is always returned as millimetres
     'Use Cached = True so we can send commands directly to the drawingarea
     dArea.Cached = True

     Counter = 1
     'Play with the Row, LeftColumn, and RightColumn values if different 
Avery stock is used.
     Row = 80 'These values are based on 850x1100, as in 8.5"x11" @ 100 dpi
     LeftColumn = 68
     RightColumn = 420 ' Increment this by 200 for each label.
     Column = LeftColumn ' toggle between Left and Right for the 2 columns

     'Still can't set the font to a particular font, such as Lucidia or 
Times New Roman, etc.
     'It may require a configuration using the FontSelector.
     'For now we select the Serif version of the current font.
     'Note the documented Font[type, size] does not allow the size 
parameter.
     Paint.Font = Font["Serif"]
     Paint.Font.Bold = False       ' Neither does this. All fonts seem 
too bold
     QRcounter = Val(TextBox1.Text) ' Get the starting code
     While Counter <= Val(TextBox2.Text) ' Are we done?
       ' Set the file to load
       QRfile = "/tmp/tmpQR" & Str$(QRcounter) & ".png"
       'The ImageLoad loads the file as a brush and we have to draw it 
at the coordinate in a particular size
       Paint.DrawImage(Image.Load(QRfile), Column + 225, Row - 30, 120, 
120) ' These values are offsets from the top left of each label.
       'Set the font size for the special Master of the system
       Paint.Font.Size = 20
       Paint.Text("some text", Column, Row)
       Paint.Font.Size = 12

... etc.

       'Done with this card
       Counter = Counter + 1
       QRcounter = QRcounter + 1
       'For a 2x8 arrangement, we switch to the second column, or if we 
are just finishing the second
       'switch back to the first
       If Column = LeftColumn Then
         Column = RightColumn
       Else
         'We switched back so now we need the next Row
         Column = LeftColumn
         Row = Row + 200 'Play with this to adjust for other Avery form 
card heights
       End If

     Wend
     'Make sure everything has been set and locked to the DrawingArea
     Paint.Stroke
   'The page is done
   Paint.End
End

Hope this helps. As I mentioned, this process works for the HP, but 
doesn't seem to be transportable.


On 14-10-09 05:37 PM, Benoît Minisini wrote:
> Le 08/10/2014 18:20, Paul Horechuk a écrit :
>> I have a successful project that formats a sheet of labels on an Avery
>> form and prints directly to an HP OfficeJet 7500 E910.
>>
>> I set the printer width to 850 and length to 1100 with a resolution of
>> 100. These may not be correct for all (PrinterWidth and length are seen
>> as 216 by 279mm), but by setting moveto coordinates within this range, I
>> do get a correct sheet of labels.
>>
>> Problems:
>>
>> On a customer printer with the same version of gambas 3.5.4, the
>> coordinates are stretched so that the labels are stretched by about 50%.
>> This is on a Canon Pixma.
>>
>> Further checking shows a print to file (as PDF) from the printer dialog,
>> resulting in:
>>
>>     *    vertical resolution is about 1/4 of what it should be
>>     *    fonts are correctly sized
>>     *    horizontal positioning is about 1/4 as well
>>     *    therefore all text is compressed into the upper left
>>     *    a QR code is about 1/4 the expected size
>>
>>
>> Changing the resolution for a direct print to Pixma has no effect.
>> Changing from 100 to 75 or to 150, results in the same stretched
>> printout. This works as expected on the HP.
>>
>> Suggestions?
>>
> The first thing I can quicky tell you: you must not use the printer
> resolution when drawing on a printer.
>
> If you use it, then something is doomed in your drawing routine, unless
> you want to draw at the pixel level, for example the thinest possible
> line (one pixel). Then you need the printer resolution, but this is the
> only case.
>
> Otherwise, in all normal printing routines, printer resolution is not
> needed.
>
> But maybe I didn't understand what you wrote...
>

-- 
Think Free ...
    Use Open Source Software





More information about the User mailing list