begin process at 2012 02 14 07:12:46
  Trouver un code source :
 
dans
 
Accueil > Forum > 

VB.NET et VB 2005

 > 

Divers

 > 

General

 > 

impression sur vb.net


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

impression sur vb.net

jeudi 27 juillet 2006 à 10:13:18 | impression sur vb.net

vara956

Salut,

je sais maitriser le composant printdocument dans mon apli, faire un apercu, imprimer mais je pige pas comment fait on pour faire une deuxieme page ?

voici un morceaux de mon code

'icone(logo)

e.Graphics.DrawString("ABB Entrelec", printfontA, Brush, 20, 35)

e.Graphics.DrawLine(blackPen, x1, y1, x2, y2)

e.Graphics.DrawString("Siège social :" & vbTab & "10 rue ampère", printfontb, Brush, 100, 60)

e.Graphics.DrawString(vbTab & vbTab & "ZI - BP 114", printfontb, Brush, 100, 75)

e.Graphics.DrawString(vbTab & vbTab & "69685 Chassieu cédex", printfontb, Brush, 100, 90)

e.Graphics.DrawImage(newImage.FromFile("C:\solufast\data\ABB_logo.gif"), 630.0F, 30.0F)

'destinataire

x = 20

y = 170

e.Graphics.DrawString("Télécopie", printfont1, Brush, x, y - 50)

e.Graphics.DrawString("De / From : " & usernom.ToString.ToUpper, printfont, Brush, x, y - 20)

e.Graphics.DrawString("Comercial : " & sel_iv.ToString.ToUpper, printfont, Brush, x, y + 20)

e.Graphics.DrawString("Tél.: " & usertel.ToString, printfont, Brush, x + 550, y - 20)

e.Graphics.DrawString("Fax.: " & userfax.ToString, printfont, Brush, x + 550, y)

e.Graphics.DrawString("Gsm.: " & sel_faxliv.ToString, printfont, Brush, x + 550, y + 20)

e.Graphics.DrawString("A / To: Société: " & sel_client.ToString.ToUpper, printfont, Brush, x, y + 60)

e.Graphics.DrawString(" Nom: " & sel_interloc.ToString.ToUpper, printfont, Brush, x, y + 80)

e.Graphics.DrawString("Tel.: " & sel_telint.ToString, printfont, Brush, x + 550, y + 100)

e.Graphics.DrawString("Fax.: " & sel_faxint.ToString, printfont, Brush, x + 550, y + 120)

bref ya d'autere ligne pour remplir la premier feuille mais je voudrai mettre des info sur le deuxieme page !! et la je bloque

c super important merci de votre aide

jeudi 27 juillet 2006 à 12:31:26 | Re : impression sur vb.net

addamsmercredi

Voilà un petit code pour montrer comment imprimer plusieurs pages.
e.HasMorePages permet d'indiquer s'il y a d'autres pages à imprimer.
A chaque page, c'est la même fonction qui est exécutée, il faut donc utiliser des variables Static pour mémoriser où ça en est.

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

    Static i as Integer = 1

    e.Graphics.DrawString("C'est la page numéro " & i, ....)

    i += 1

    If (tout est imprimé) Then
        e.HasMorePages = False
    Else
        e.HasMorePages = True
    End If

End Sub

jeudi 27 juillet 2006 à 14:22:07 | Re : impression sur vb.net

vara956

merci d'avoir répondu mais j'ai du mal a comprendre ce qui lui dits qui est dans la page 2, Comme c 'est moi qui lui dit a chaque ligne sa position celle ci ne s'incrémente pas seul  bref comment lui faire comprendre que tel et tel ligne doivent etre sur la page 2

Puis je t'envoye le code de l'impression ? pour que tu vois ce que je veux dire
!!

Merci a toi encore
seb

voici le code complet de l'impression :

PrivateSub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

 

Dim drawFormat AsNew StringFormat

Dim blackPen AsNew Pen(Color.Black, 1)

Dim x AsSingle

Dim y AsSingle

Dim linesPerPage AsSingle = 0

Dim width AsSingle = 200.0F

Dim height AsSingle = 50.0F

Dim drawRect AsNew RectangleF(x, y, width, height)

Dim printfont AsNew Font("Arial", 13)

Dim printfontA AsNew Font("Arial", 16)

Dim printfontb AsNew Font("Arial", 8)

Dim printfont1 AsNew Font("Arial", 18)

Dim printfont2 AsNew Font("Arial", 20)

Dim Brush AsNew SolidBrush(Color.Black)

 

 

Try

'ligne

Dim x1 AsSingle = 20.0F

Dim y1 AsSingle = 60.0F

Dim x2 AsSingle = 600.0F

Dim y2 AsSingle = 60.0F

linesPerPage = e.MarginBounds.Height / printfont.GetHeight(e.Graphics)

'icone(logo)

e.Graphics.DrawString("ABB Entrelec", printfontA, Brush, 20, 35, drawFormat)

e.Graphics.DrawLine(blackPen, x1, y1, x2, y2)

e.Graphics.DrawString("Siège social :" & vbTab & "10 rue ampère", printfontb, Brush, 100, 60, drawFormat)

e.Graphics.DrawString(vbTab & vbTab & "ZI - BP 114", printfontb, Brush, 100, 75, drawFormat)

e.Graphics.DrawString(vbTab & vbTab & "69685 Chassieu cédex", printfontb, Brush, 100, 90, drawFormat)

e.Graphics.DrawImage(newImage.FromFile("C:\solufast\data\ABB_logo.gif"), 630.0F, 30.0F)

'destinataire

x = 20

y = 170

e.Graphics.DrawString("Télécopie", printfont1, Brush, x, y - 50, drawFormat)

e.Graphics.DrawString("De / From : " & usernom.ToString.ToUpper, printfont, Brush, x, y - 20, drawFormat)

e.Graphics.DrawString("Comercial : " & sel_iv.ToString.ToUpper, printfont, Brush, x, y + 20, drawFormat)

e.Graphics.DrawString("Tél.: " & usertel.ToString, printfont, Brush, x + 550, y - 20, drawFormat)

e.Graphics.DrawString("Fax.: " & userfax.ToString, printfont, Brush, x + 550, y, drawFormat)

e.Graphics.DrawString("Gsm.: " & sel_faxliv.ToString, printfont, Brush, x + 550, y + 20, drawFormat)

e.Graphics.DrawString("A / To: Société: " & sel_client.ToString.ToUpper, printfont, Brush, x, y + 60, drawFormat)

e.Graphics.DrawString(" Nom: " & sel_interloc.ToString.ToUpper, printfont, Brush, x, y + 80, drawFormat)

e.Graphics.DrawString("Tel.: " & sel_telint.ToString, printfont, Brush, x + 550, y + 60, drawFormat)

e.Graphics.DrawString("Fax.: " & sel_faxint.ToString, printfont, Brush, x + 550, y + 80, drawFormat)

'info devis

e.Graphics.DrawString("V/Réf.: " & Affairedevis.ToString, printfont, Brush, x, y + 140, drawFormat)

e.Graphics.DrawString("Offre de prix N° : " & numdevis.ToString.ToUpper, printfont, Brush, x, y + 160, drawFormat)

e.Graphics.DrawString("Rueil, le " &

Date.Now.Today.ToLongDateString, printfont, Brush, x + 450, y + 180, drawFormat)

e.Graphics.DrawString("Madame, Monsieur,", printfont, Brush, x, y + 220, drawFormat)

e.Graphics.DrawString("En réponse à votre demande pour l'affaire citée en objet, nous vous prions de bien vouloir " & vbCrLf & " trouver ci-joint notre meilleur offre de prix pour la founiture de matériel Basse Tension au" & vbCrLf & "prix Net total H.T de : ", printfont, Brush, x, y + 260, drawFormat)

'e.Graphics.DrawString("vouloir trouver ci-joint notre meilleur offre de prix pour la founiture de matériel Basse" & vbCrLf & "Tension au prix Net total H.T de : ", printfont, Brush, x, y + 260)

e.Graphics.DrawString("Cette proposition s'entend avec les conditions suivantes : ", printfont, Brush, x, y + 350, drawFormat)

e.Graphics.DrawString("- Condition de livraison" & vbTab & ": Port à facturer", printfont, Brush, 40, y + 370, drawFormat)

e.Graphics.DrawString("- Délai de livraison" & vbTab & ": Voir Page matériel", printfont, Brush, 40, y + 390, drawFormat)

If etude = TrueThen

e.Graphics.DrawString("- Condition de paiement" & vbTab & ": Par distributeur", printfont, Brush, 40, y + 410, drawFormat)

Else

e.Graphics.DrawString("- Condition de paiement" & vbTab & ": 60 jours", printfont, Brush, 40, y + 410, drawFormat)

EndIf

e.Graphics.DrawString("- Validité de l'offre" & vbTab & ": " & valide.ToString.ToUpper, printfont, Brush, 40, y + 430, drawFormat)

e.Graphics.DrawString("La présente offre est soumise au condition générales de vente en vigueur dans la société" & vbCrLf & "ABB Entrelec, conditions disponibles, dans nos catalogues ou sur simple demande auprès" & vbCrLf & "de votre interlocuteur commercial.", printfont, Brush, 20, y + 470, drawFormat)

e.Graphics.DrawString("Espérant avoir répondu à votre demande et restant à votre entière disposition pour tous" & vbCrLf & "renseignements complémentaire nécessaires à vous-même ou vos services nous vous" & vbCrLf & "prions de croire Madame, Monsieur en l'expression de nos sincères salutations.", printfont, Brush, 20, y + 550, drawFormat)

If Len(infoclient.ToString) <> 0 Then

e.Graphics.DrawString("****************************************** ATTENTION ******************************************", printfont, Brush, 20, y + 670, drawFormat)

e.Graphics.DrawString(infoclient.ToString.ToUpper, printfont, Brush, 40, y + 710, drawFormat)

EndIf

e.Graphics.DrawString("Solufast version ABB V1.00", printfontb, Brush, 360, 1100, drawFormat)

 

'mettre c info sur la page page(2)

e.Graphics.DrawString("Nom de l'affaire: " & Affairedevis.ToString, printfontA, Brush, x, y + 1500, drawFormat)

e.Graphics.DrawString("N° offre: " & numdevis.ToString.ToUpper, printfontb, Brush, x, y + 1520, drawFormat)

e.Graphics.DrawString("Date du chiffrage: " &

Date.Now.Today.ToLongDateString, printfontb, Brush, x, y + 1540, drawFormat)

e.Graphics.DrawString("Nom du demandeur: " & sel_interloc.ToString.ToUpper, printfontb, Brush, x, y + 1560, drawFormat)

e.Graphics.DrawString("Nom de la société: " & sel_client.ToString.ToUpper, printfontb, Brush, x, y + 1580, drawFormat)

If etude = TrueThen

e.Graphics.DrawString("Type de chiffrage: Etude de prix", printfontb, Brush, x + 500, y + 1520, drawFormat)

Else

e.Graphics.DrawString("Type de chiffrage: Offre de prix", printfontb, Brush, x + 500, y + 1520, drawFormat)

EndIf

e.Graphics.DrawString("Liste du matériel", printfont2, Brush, x + 350, y + 1550, drawFormat)

'e.Graphics.DrawLine(blackPen, x1, y1, x2, y2)

e.Graphics.DrawString("Référence" & usernom.ToString.ToUpper, printfontb, Brush, x, y + 1620, drawFormat)

e.Graphics.DrawString("Désignation" & sel_iv.ToString.ToUpper, printfontb, Brush, x + 50, y + 1620, drawFormat)

e.Graphics.DrawString("Qts." & usertel.ToString, printfontb, Brush, x + 150, y + 1620, drawFormat)

e.Graphics.DrawString("Col." & sel_faxint.ToString, printfontb, Brush, x + 200, y + 1620, drawFormat)

e.Graphics.DrawString("Prix Net" & userfax.ToString, printfontb, Brush, x + 250, y + 1620, drawFormat)

e.Graphics.DrawString("Délai" & sel_faxliv.ToString, printfontb, Brush, x + 300, y + 1620, drawFormat)

e.Graphics.DrawString("Info" & sel_telint.ToString, printfontb, Brush, x + 350, y + 1620, drawFormat)

y1 = y1 + 200

y2 = y2 + 1620

'e.Graphics.DrawLine(blackPen, x1, y1, x2, y2)

e.HasMorePages =

True

 

Catch ex As Exception

MsgBox(ex.Message, MsgBoxStyle.Critical)

EndTry
jeudi 27 juillet 2006 à 14:23:51 | Re : impression sur vb.net

vara956

PS :  la partie avant le ' a mettre sur la page 2 fonctionne tres bien sur une page ,

 

jeudi 27 juillet 2006 à 14:41:25 | Re : impression sur vb.net

addamsmercredi

Réponse acceptée !

Si il y a toujours 2 pages, tu peux faire comme ceci. J'espère que ça te sera plus clair.

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

      Static Premiere as Boolean = True

      If Premiere then
          'Ici c'est la première page

          Premiere = False
          e.HasMorePages = True
      Else
          'Ici c'est la deuxième page

          Premiere = True
          e.HasMorePages = False
      End if

End Sub

jeudi 27 juillet 2006 à 15:51:49 | Re : impression sur vb.net

vara956

encore merci a toi
ca marche je devrai y comprendre  meiux


Cette discussion est classée dans : graphics, drawstring, tostring, brush, printfont


Répondre à ce message

Sujets en rapport avec ce message

l'impression avec e.graphic.... [ par vara956 ] salutvoila je fais une application pour faire des devis,tout fonctionne correctement meme l'impression,mais je voudrait mettre certaine lignes en gras Boucle For dans boucle While pour impression sur plusieurs pages ??!! [ par gnes ] Salut, j'ai un gros souci avec mon application !!!!!!!!! Je fais une impression d'une liste, et ma liste est très longue, Pour mon impression, il ne m Problème en VB.Net et DrawString (erreur générique GDI+) [ par azerty25 ] Bonjour J'ai le code suivant, pour écrire du texte sur un nouveau formulaire et la fonction drawstring me renvoye une erreur générique GDI+ si showint Utilisation de la classe graphics et drawstring [ par frk22 ] Bonjour a tous !!!Je développe sous vb2008 studio et mon souci est le suivant :   j utilise une forme dans laquelle je place du texte par la classe "g Imprimé sur du papier continu [ par supermatcho ] Bonjours, je doit imprimer sur du papier thermal en alimentation continu de papier.voici ma partie du code,PrivateSub</font Changer couleur drawstring [ par angelblood ] Salut a tous, Je vous explique : J'ai des drawstring avec une couleur et je voudrais que lorsque que la souris arrive dans la zone elle change de coul problème pour imprimer [ par baltazar85 ] Bonjour,alors voila j'ai fais une classe d'impression en vb.net mais le problème c'est que je n'arrive pas a envoyer de donnée a ma classe.Les données problème d'impression class [ par baltazar85 ] Bonjour,alors voila j'ai fais une classe d'impression en vb.net mais le problème c'est que je n'arrive pas a envoyer de donnée a ma classe.Les données problème d'impression multi page [ par joujma5 ] bonjour, j'ai procédé par le drawing pour imprimer un état, mais je retrouve un problème lorsque l'impression s'étale sur plus qu'une page, je ne sait Nouvelle classe Image_Class : traitement trop long... [ par fsintegral ] Bonjour ! Tout d'abord, Bonne Année à tous ! Puis, la situation : 1) Je suis débutant : je ne sais utiliser que [b]Graphics[/b]. 2) Je suis en train


Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 4,025 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales