Si vous avez Windows 10 vous avez déja une imprimante PDF. Si vous avez une version antérieure de Windows, alors installer une imprimante PDF si ce n'est pas encore fait.
Le code vous permet de choisir une imprimante puis imprime 150 ligne sur 3 pages.
Pour chaque page, il y a aura l'impression d'un entête et d'un pied de page contenant un compteur de page.
Code : Tout sélectionner
; PB 5.40 - DEMO PrinterVectorOutput()
Declare PrintHeader()
Declare PrintFooter()
Global CountLines, CountPage, Top = 20, y
LoadFont(0, "Courier New", 10)
;Choix de l'imprimante
If PrintRequester()
;Initialise l'imprimante et démarre l'impression
;On donne un nom qui apparaîtra dans la file d'attente d'impression
If StartPrinting("PureBasic Test")
;Initialisation dessin vectoriel sur la sortie imprimante
If StartVectorDrawing(PrinterVectorOutput())
;Impression des lignes détail
For Line = 1 To 150
If CountLines = 48 Or Line = 1
CountLines = 0
If Line <> 1
NewVectorPage()
EndIf
PrintHeader()
PrintFooter()
EndIf
CountLines + 1
y = Top + (CountLines * 15)
MovePathCursor(50, y) : DrawVectorText("Item col1 line " + Str(Line))
MovePathCursor(450, y) : DrawVectorText("Item col2 line " + RSet(Str(Line), 3, " "))
Next
StopVectorDrawing()
EndIf
StopPrinting()
EndIf
EndIf
Procedure PrintHeader()
VectorFont(FontID(0), 15)
VectorSourceColor(RGBA(0, 0, 0, 200))
MovePathCursor(10, 10)
DrawVectorText("DEMO PrinterVectorOutput()")
;Affichage du slogan PureBasic
VectorFont(FontID(0), 20)
VectorSourceColor(RGBA(255, 0, 0, 128))
RotateCoordinates(30, 50, 90)
MovePathCursor(30, 50)
DrawVectorText("Make with Pure Basic : What else !")
;Retour à la normal pour les ligne détails
RotateCoordinates(30, 50, -90)
VectorFont(FontID(0), 10)
VectorSourceColor(RGBA(0, 0, 0, 255))
EndProcedure
Procedure PrintFooter()
VectorFont(FontID(0), 10)
VectorSourceColor(RGBA(0, 0, 0, 255))
MovePathCursor(10, VectorOutputHeight() - 50)
DrawVectorText("Imprimé avec PureBasic 5.40 LTS Beta1")
CountPage + 1
MovePathCursor(VectorOutputWidth() - 60, VectorOutputHeight() - 50)
DrawVectorText("Page " + Str(CountPage))
EndProcedure
Merci d'avance.