Zweckform Etiketten drucken für PB3.94
Verfasst: 21.05.2006 17:50
Die Lösung, für alle dies brauchen können
Habe den Code von Maddin verwendet für die Seitenanpassung
Code für Zweckform Nr. 3657
man kann das erste Etikett definieren an dem begonnen werden soll (siehe posetix und posetiy).
die Randeinstellung oben und links kann definiert werden (unter Berücksichtigung der pysikalischen Ränder)
und evtl. die Etikettengröße, wenn 4 nebeneinander und 10 untereinander stehen.
Auf andere Formate kanns aber leicht angepasst werden
gruß Gerhard
Habe den Code von Maddin verwendet für die Seitenanpassung
Code für Zweckform Nr. 3657
man kann das erste Etikett definieren an dem begonnen werden soll (siehe posetix und posetiy).
die Randeinstellung oben und links kann definiert werden (unter Berücksichtigung der pysikalischen Ränder)
und evtl. die Etikettengröße, wenn 4 nebeneinander und 10 untereinander stehen.
Auf andere Formate kanns aber leicht angepasst werden
gruß Gerhard
Code: Alles auswählen
Global obRa.f , liRa.f , Etbr.f , Etho.f , liRax.f , obRax.f , maximumkanal ; text1$ , text2$
posetix = 3 ; Etikett 1-4 in x-Richtung
posetiy = 2 ; Reihe 1-10 in y-Richtung
maximumkanal = 85 ; Stückzahl der gewünschten Etiketten
text1$ = "Etikettentest" ; erste Zeile
text2$ = " funktioniert" ; zweite Zeile
obRa = 17 ; obere Randeinstellung ( für Epson Laserprinter)
liRa = 3 ; linke Randeinstellung
Etbr = 48.5 ; Etiketten Breite
Etho = 25.4 ; Etiketten Höhe
Enumeration (1)
#Image
#Box
#Circle
#Text
#Ellipse
#Line
EndEnumeration
Structure PrinterPys
pgx.l ;physik. Breite gesamt deviceunits
pgy.l ;physik. Höhe
width.f ;druckbarer Bereich in mm
height.f
dpmmx.f ;horz. Auflösung dots per mm
dpmmy.f ;vert. Auflösung dots per mm
nulx.f ;druckbar links in mm
nuly.f ;druckbar oben
endx.f ;druckbar recht. Rand in mm
endy.f ;druckbar unter. Rand
EndStructure
Structure PrinterPage
Printer.PrinterPys
;alle in mm
rnulx.l ;Nullpos mit Rand links
rnuly.l ;Nullpos mit Rand links
rpax.l ;mit Rand Breite
rpay.l ;mit Rand Höhe
EndStructure
Global Page.PrinterPage
Procedure.b Init_Printer(job.s)
hDC.l
HorRes.l
VerRes.l
pysLeft.l
pysTop.l
If PrintRequester() = 0
ProcedureReturn #False
EndIf
StartPrinting(job)
hDC = StartDrawing(PrinterOutput())
;linke obere Ecke vom Blattrand
pysLeft = GetDeviceCaps_(hDC,#PHYSICALOFFSETX)
pysTop = GetDeviceCaps_(hDC,#PHYSICALOFFSETY)
;device units ganze Breite
Page\Printer\pgx = GetDeviceCaps_(hDC,#PHYSICALWIDTH)
Page\Printer\pgy = GetDeviceCaps_(hDC,#PHYSICALHEIGHT)
;Auflösung in dpi
HorRes = GetDeviceCaps_(hDC,#HORZRES)
VerRes = GetDeviceCaps_(hDC,#VERTRES)
;Druckbarer Bereich in mm
Page\Printer\width = GetDeviceCaps_(hDC,#HORZSIZE)
Page\Printer\height = GetDeviceCaps_(hDC,#VERTSIZE)
;Auflösung in mm
Page\Printer\dpmmx = HorRes / Page\Printer\width
Page\Printer\dpmmy = VerRes / Page\Printer\height
;pysk Rand berechnen und in mm umrechnen
Page\Printer\endx = Page\Printer\pgx - HorRes - pysLeft
Page\Printer\endy = Page\Printer\pgy - VerRes - pysTop
Page\Printer\nulx = pysLeft / Page\Printer\dpmmx
Page\Printer\nuly = pysTop / Page\Printer\dpmmy
Page\Printer\endx / Page\Printer\dpmmx
Page\Printer\endy / Page\Printer\dpmmy
ProcedureReturn #True
EndProcedure
;mm-Breite aus Auflösung
Procedure.l xmm(x.f)
ProcedureReturn = x * Page\Printer\dpmmx
EndProcedure
;mm-Länge aus Auflösung
Procedure.l ymm(y.f)
ProcedureReturn = y * Page\Printer\dpmmy
EndProcedure
;Rechnet die Größenangabe des Font aus
;Faktor 3.8 durch Vergleich mit anderen Ausdrucken
;aus Windows heraus ermittelt
Procedure.l Fontpointsize(p)
ProcedureReturn Int(p * Page\Printer\dpmmy / 3.8)
EndProcedure
Procedure Deinit_printer()
StopDrawing(): StopPrinting()
EndProcedure
Procedure Drucke_Element(Obj.l,ObjID.l,xa.f,ya.f,xe.f,ye.f,width.f,col.l,s.s)
n1.f
n2.f
If Abs(width) > 0
n1 = 0
n2 = Abs(width) * Page\Printer\dpmmx
Else
n1 = 0
n2 = 1
EndIf
If col <> 0
FrontColor(Red(col),Green(col),Blue(col))
EndIf
;Koordinaten / Größen in mm * Pixel = Gesamtpixel umrechnen
xa = xmm(xa)
xe = xmm(xe) ;Auch Radien von Kreis und Ellipse
ya = xmm(ya)
ye = xmm(ye) ; "
Select Obj
Case #Image
DrawImage(UseImage(ObjID),xa,ya,xe,ye)
Case #Box
While (n1 < n2):Box(xa+n1,ya+n1,xe-n1-n1,ye-n1-n1):n1 + 1:Wend
Case #Circle
While (n1 < n2):Circle(xa,ya,xe-n1):n1 + 1:Wend
Case #Text
Locate(xa,ya)
DrawText(s)
Case #Ellipse
While (n1 < n2):Ellipse(xa,ya,xe-n1,ye-n1):n1 + 1:Wend
Case #Line
While (n1 < n2)
If width > 0 ;Dicke Größer 0 -> in x-Richtung Linien zeichnen
LineXY(xa+n1,ya,xe+n1,ye):n1 + 1
Else ; in y-Richtung Linien zeichnen
LineXY(xa,ya+n1,xe,ye+n1):n1 + 1
EndIf
;Horizontal- und Vertikallinien besser mit Box() und Drawmode(<>4) zeichnen
Wend
EndSelect
FrontColor(0,0,0)
EndProcedure
;Hier ggF. denPfad zum Bild eintragen
;LoadImage(100,"")
druckfont20=LoadFont(0, "Arial", Fontpointsize(20))
druckfont10=LoadFont(0, "Arial", Fontpointsize(10))
If Init_Printer("test") = #True
n.l
DrawingMode(4)
; Etikett x
If posetix = 1 : liRax = liRa + 0 * Etbr
ElseIf posetix = 2 : liRax = liRa + 1 * Etbr
ElseIf posetix = 3 : liRax = liRa + 2 * Etbr
ElseIf posetix = 4 : liRax = liRa + 3 * Etbr : EndIf
; Etikett y
If posetiy = 1 : obRax = obRa + 0 * Etho
ElseIf posetiy = 2 : obRax = obRa + 1 * Etho
ElseIf posetiy = 3 : obRax = obRa + 2 * Etho
ElseIf posetiy = 4 : obRax = obRa + 3 * Etho
ElseIf posetiy = 5 : obRax = obRa + 4 * Etho
ElseIf posetiy = 6 : obRax = obRa + 5 * Etho
ElseIf posetiy = 7 : obRax = obRa + 6 * Etho
ElseIf posetiy = 8 : obRax = obRa + 7 * Etho
ElseIf posetiy = 9 : obRax = obRa + 8 * Etho
ElseIf posetiy =10 : obRax = obRa + 9 * Etho : EndIf
; liRax = liRa
; obRax = obRa
; posetix = 1
; posetiy = 0
For i = 1 To maximumkanal
;If multi(i)\id3 > 0
Drucke_Element(#Box,0,liRax,obRax,Etbr,Etho,0,RGB(0,0,0),"")
DrawingFont(druckfont20) : textgroesse=(12/3.8)+2
Drucke_Element(#Text,0,liRax+2,obRax+2 +(l*textgroesse),0,0,0,0,text1$)
DrawingFont(druckfont10) : textgroesse=(12/3.8)+2
Drucke_Element(#Text,0,liRax+2,obRax+10 +(l*textgroesse),0,0,0,0,text2$)
liRax + Etbr : posetix + 1
If posetix > 4 : posetix = 0 : posetiy + 1 : posetix + 1 : liRax = liRa : obRax + Etho : EndIf
If posetiy > 10 : NewPrinterPage() : liRax.f = liRa : obRax.f = obRa : posetix = 1 : posetiy = 1 : EndIf
;EndIf
Next
Deinit_printer()
EndIf