Dans codeArchiv : il y avait ce très bon exemple d'impression de Fred.
Pour les portions colorées dans un cercle FillAréa fonctionne mal avec les imprimantes
avec aussi l'impression une ListView à partir d'une capture en image de la zone du gadget.
Code : Tout sélectionner
; English forum:
; Author: Rui Carvalho (updated for PB4.00 by blbltheworm)
; Date: 01. March 2003
; OS: Windows
; Demo: Yes
;***************************
;Super Printer - DPI indepent print
;by Rui Carvalho - 2003
;
;Part of GIA - Lift Management Software
;Freeware
;***************************
;rui-carvalho@bigfoot.com
Declare ycm(x.f)
Declare xcm(x.f)
;
;Original printer code by Fred
;
hwnd=OpenWindow(1,0,0,340,280,"test impression listview",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0,10,10,320,260,"Nom",100,#PB_ListIcon_FullRowSelect |#PB_ListIcon_AlwaysShowSelection )
SendMessage_(GadgetID(0),#LVM_SETEXTENDEDLISTVIEWSTYLE,#LVS_EX_GRIDLINES,#LVS_EX_GRIDLINES)
For i = 1 To 3
AddGadgetColumn(0,i,"Col : "+Str(i),70)
Next
For i = 0 To 10 : AddGadgetItem(0,-1,"List Item #" + Str(i)+Chr(10)+"pomme"+Chr(10)+"poire"+Chr(10)+"prune") : Next
CreateImage(0,GadgetWidth(0),GadgetHeight(0))
DC=StartDrawing(ImageOutput(0))
For i=1 To 50:WindowEvent():Next i ; boucle de dessin des boutons sur la fenetre avant screenshot
BitBlt_(DC,0,0,GadgetWidth(0),GadgetHeight(0),GetDC_(hwnd),GadgetX(0),GadgetY(0),#SRCCOPY)
StopDrawing()
Delay(2000)
If PrintRequester()
If StartPrinting("PureBasic Test")
LoadFont(0, "Arial", ycm(0.4))
LoadFont(1, "Curlz MT", ycm(1))
If StartDrawing(PrinterOutput())
FrontColor(RGB(240,220,20))
Box(xcm(4), ycm(7), xcm(2), ycm(6)) ; draw a 4cm by 7cm square x=2cm y=6cm
DrawingMode(#PB_2DDrawing_Outlined ) ; figures géométriques en traits
DrawingFont(FontID(0));4mm font size
; locate at 15cm by 14cm
DrawRotatedText(xcm(15), ycm(14), "PUREBASIC IS A LEGEND",90, RGB(255, 0, 255))
DrawRotatedText(xcm(15), ycm(14), "PUREBASIC IS A LEGEND",39, RGB(0, 0, 255))
DrawRotatedText(xcm(15), ycm(14), "PUREBASIC IS A LEGEND",347, RGB(0, 255, 0))
DrawRotatedText(xcm(15), ycm(14), "PUREBASIC IS A LEGEND",296, RGB(255, 255, 0))
DrawRotatedText(xcm(15), ycm(14), "PUREBASIC IS A LEGEND",244, RGB(255, 0, 0))
DrawRotatedText(xcm(15), ycm(14), "PUREBASIC IS A LEGEND",193, RGB(240,150,20))
DrawRotatedText(xcm(15), ycm(14), "PUREBASIC IS A LEGEND",142, RGB(225, 225, 225))
Circle(xcm(15), ycm(14),ycm(6.6),RGB(0,0,255)) ; draw a 15cm by 14cm circle rayon y=5cm
; locate at 15cm by 5,5cm
DrawText(xcm(14), ycm(5.5),"PureBasic Printer Test",RGB(0,0,255),RGB(255,255,255))
DrawingFont(FontID(1)); 1 cm font size
; locate at 7cm by 25cm
DrawText(xcm(7), ycm(25),"PUREBASIC TEN YEAR ALREADY",RGB(128,128,128),RGB(255,255,255))
If LoadImage(1,"..\PureBasic\Examples\Sources\Data\PureBasicLogo.bmp"); The logo bitmap is bigger
ResizeImage(1, xcm(8), ycm(3)) ; resize image for 8cm by 3cm
DrawImage(ImageID(1), xcm(1), ycm(1)) ; draw image at 1cm by 1cm
Else
MessageRequester("", "2", 0)
EndIf
FrontColor(RGB(100,100,100))
Box(xcm(2), ycm(5), xcm(6), ycm(10)) ; draw a 2cm by 5cm square x=6cm y=10cm
For i=1 To 360
LineXY(xcm(5), ycm(20),Cos(Radian(342+(i/5)))*(ycm(5))+xcm(5),Sin(Radian(342+(i/5)))*(ycm(5))+ycm(20),RGB(255,0,0))
LineXY(xcm(5), ycm(20),Cos(Radian(54+(i/5)))*(ycm(5))+xcm(5),Sin(Radian(54+(i/5)))*(ycm(5))+ycm(20),RGB(255,0,255))
LineXY(xcm(5), ycm(20),Cos(Radian(126+(i/5)))*(ycm(5))+xcm(5),Sin(Radian(126+(i/5)))*(ycm(5))+ycm(20),RGB(0,0,255))
LineXY(xcm(5), ycm(20),Cos(Radian(198+(i/5)))*(ycm(5))+xcm(5),Sin(Radian(198+(i/5)))*(ycm(5))+ycm(20),RGB(255,255,0))
LineXY(xcm(5), ycm(20),Cos(Radian(270+(i/5)))*(ycm(5))+xcm(5),Sin(Radian(270+(i/5)))*(ycm(5))+ycm(20),RGB(0,255,0))
Next i
Circle(xcm(5), ycm(20),ycm(5),RGB(0,0,0)) ; draw a 5cm by 20cm circle rayon y=5cm
ResizeImage(0, xcm(10), ycm(13))
DrawImage(ImageID(0), xcm(3), ycm(28))
StopDrawing()
EndIf
StopPrinting()
EndIf
EndIf
;**** the trick !!!! ****
Procedure xcm(x.f)
result = x * (PrinterPageWidth()/21) ; 21cm A4
ProcedureReturn result
EndProcedure
Procedure ycm(x.f)
result = x * (PrinterPageWidth()/29.7) ; 29,7cm A4
ProcedureReturn result
EndProcedure
;Tested with fineprintpdf in multiple DPI's
;and on Xerox DC440 laser printer