Page loading

Share your opinion
What do you think about gambaslinux.fr?
 
Interesting
It miss some informations
Excellent website
Results
WIDGETS GAMBAS
GAMBAS 3 SOFTWARES
TUTORIALS
Library
Printer and Gambas - Print a Textarea
IMPRIMER LE CONTENU D'UNE TEXTAREA


Imprimer une TextArea


Réalisé par taoteblues


Vous avez la possibilité d'utiliser le code basique suivant:


Public Sub Button_Click()

Draw.Begin(Printer)
Draw.Text(TextArea1.Text, 200, 200, Printer.With, Printer.Height)
Draw.End

End


ou le code suivant qui permet d'imprimer le contenu d'une TextArea en tenant compte des limites de la page, de ne pas couper de mot, de faire un retour à la ligne et de continuer l'impression sur les pages suivantes.


PUBLIC SUB Button_Click()


DIM Ileft AS Integer

DIM IRight AS Integer

DIM ITop AS Integer

DIM IBot AS Integer

DIM textaimprimer AS String

DIM ITextposY AS Integer

DIM ITextPosX AS Integer

DIM ITextposX1 AS Integer

DIM Txtligne AS String

DIM Nextword AS String

DIM IprinterIwidth AS Integer

DIM IprinterIheight AS Integer


Printer.Size = "A4"


ILeft = 200

IRight = 800

ITop = 200

IBot = 200

IprinterIheight = Printer.Height - ITop - IBot - 400

IprinterIwidth = Printer.Width - ILeft - IRight



' nous découpons le texte à chaque saut de ligne

ITextPosX = 200

ITextposY = 100


'début d'impression

Draw.Begin(Printer)


textaimprimer = TextArea1.Text

FOR EACH Txtligne IN Split(textaimprimer, "n")


'Réglages personnels des bordures et de la taille des caractères


ITextPosX = 200

ITextposY = ITextposY + Draw.TextHeight("TaotE")


Draw.ForeColor = Color.Black

Draw.Font.Bold = FALSE

Draw.Font.Italic = FALSE

Draw.Font.Underline = FALSE

Draw.Font.Size = 10



' nous découpons chaque ligne en mots


FOR EACH NextWord IN Split(TxtLigne, " ")


IF ITextposY >= IprinterIheight THEN

ITextposY = 100

Printer.NewPage

ENDIF

'si la longueur du mot trop grande


ITextposX1 = ITextposX + Draw.TextWidth(NextWord & " ")

IF ITextPosX1 >= IprinterIwidth THEN

ITextPosX = 200

ITextposY = ITextposY + Draw.TextHeight("TaoteBlueS")

ENDIF

' nous passons le mot à l'impression

Draw.Text(NextWord & " ", ILeft + ITextPosX, ITop + ITextposY)

ITextposX = ITextposX + Draw.TextWidth(NextWord & " ")

NEXT


NEXT


Draw.End

END






Creation date : 19/10/2009 @ 16:18
Last update : 19/10/2009 @ 16:19
Category : Printer and Gambas
Page read 6119 times


Print the article Print the article


react.gifReactions to this article


Reaction #3 

by ron 14/04/2013 @ 15:34

Merci, Tao.   ....   tu m'aide bien !

Ron.

Reaction #2 

by spheris 18/08/2010 @ 23:29

JJM,
en fait dans les propriétés de ton projet, il faut que tu ajoutes la bibliothèque de la gestion d'imprimantes en cochant gb.qt.ext si tu utilises qt. ainsi tu n'auras plus le message.
Il te manquait simplement un composant.


Reaction #1 

by JJM 17/08/2010 @ 23:12

Bonjour,
J'essaie d'utiliser ce code mais j'obtiens 'Unknown identifier: Printer'
Que dois-je faire?
Merci pour votre aide.

QUICK MENU
SEARCH




LANGUAGE
COMPONENTS
Other
LANGUAGE
Where, who?
VISITS

   visitors

   visitors online

ARCHIVES GAMBAS 1/2
^ Top ^