|
-
Mar 31st, 2015, 10:06 AM
#1
Thread Starter
Member
-
Mar 31st, 2015, 10:16 AM
#2
Re: How to print documents
Post your code, and i'll tell you what to change
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 31st, 2015, 10:31 AM
#3
Thread Starter
Member
Re: How to print documents
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
PrintPreviewControl1.Document = PrintDocument1
End Sub
Private Sub TreeView1_NodeMouseClick(sender As Object, e As TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
PrintPreviewControl1.StartPage = e.Node.Tag
End Sub
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim p1 As projeto = New projeto
Dim c1 As cabo = New cabo
Dim f0 As Font = New Font("Arial", 16, FontStyle.Bold)
Dim f1 As Font = New Font("Arial", 10, FontStyle.Bold)
Dim f2 As Font = New Font("Arial", 10)
Dim format As StringFormat = New StringFormat()
format.Alignment = StringAlignment.Center
format.LineAlignment = StringAlignment.Center
Dim rect1 As Rectangle
Dim rect2 As Rectangle
Dim rect3 As Rectangle
Dim rect4 As Rectangle
Dim rect5 As Rectangle
e.Graphics.DrawLine(Pens.Black, 50, 50, 777, 50)
e.Graphics.DrawString("Lista de Cabos", f0, Brushes.Black, 330, 70)
rect1 = New Rectangle(50, 130, 140, 60)
rect2 = New Rectangle(190, 130, 110, 60)
rect3 = New Rectangle(300, 130, 70, 60)
rect4 = New Rectangle(370, 130, 350, 60)
rect5 = New Rectangle(720, 130, 57, 60)
e.Graphics.DrawString("No. CABO", f1, Brushes.Black, rect1, format)
e.Graphics.DrawString("FORMAÇÃO" & vbCrLf & "(mm²)", f1, Brushes.Black, rect2, format)
e.Graphics.DrawString("COMP" & vbCrLf & "(M)", f1, Brushes.Black, rect3, format)
e.Graphics.DrawString("ORIGEM - PERCURSO - DESTINO", f1, Brushes.Black, rect4, format)
e.Graphics.DrawString("REV", f1, Brushes.Black, rect5, format)
e.Graphics.DrawRectangle(Pens.Black, rect1)
e.Graphics.DrawRectangle(Pens.Black, rect2)
e.Graphics.DrawRectangle(Pens.Black, rect3)
e.Graphics.DrawRectangle(Pens.Black, rect4)
e.Graphics.DrawRectangle(Pens.Black, rect5)
Dim arr As Object
Dim aux As Object
Dim nallc As Integer
nallc = p1.getTodosCaboId(arr)
Dim s As Integer
Dim inc As Integer
For i = ncab To nallc
c1.setID(arr(i))
c1.getRotaIds(aux)
aux = comprimir(aux)
For k = nlinha To UBound(aux)
If (k = 0) Then
rect2 = New Rectangle(190, 200 + s, 110, 20)
rect3 = New Rectangle(300, 200 + s, 70, 20)
rect5 = New Rectangle(720, 200 + s, 57, 20)
e.Graphics.DrawString(c1.getNome, f2, Brushes.Black, 50, 200 + s)
e.Graphics.DrawString(c1.getTipo, f2, Brushes.Black, rect2, format)
e.Graphics.DrawString(c1.getComprimento, f2, Brushes.Black, rect3, format)
e.Graphics.DrawString(aux(k), f2, Brushes.Black, 370, 200 + s)
e.Graphics.DrawString(c1.getRevisao, f2, Brushes.Black, rect5, format)
Else : e.Graphics.DrawString(aux(k), f2, Brushes.Black, 370, 200 + s)
End If
s += 20
inc += 1
nlinha += 1
If (inc >= 42) Then
GoTo QuebraPag
End If
Next
s += 20
inc += 1
ncab += 1
nlinha = 0
If (inc >= 42) Then
GoTo QuebraPag
End If
Next
QuebraPag:
e.Graphics.DrawString("nº ", f2, Brushes.Black, 50, 1080)
e.Graphics.DrawString("nº Copem", f2, Brushes.Black, 370, 1080)
e.Graphics.DrawString("FL " & npag & " / ", f2, Brushes.Black, 720, 1080)
e.HasMorePages = (ncab <= nallc)
Dim no As TreeNode
no = TreeView1.Nodes.Add(npag)
no.Tag = npag - 1
npag += 1
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
PrintDialog1.Document = PrintDocument1
PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
If PrintDialog1.ShowDialog = DialogResult.OK Then
PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
PrintDocument1.Print()
End If
End Sub
-
Mar 31st, 2015, 11:23 AM
#4
Re: How to print documents
try using a printpreviewdialog:
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.WindowState = FormWindowState.Maximized
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'your print code
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 31st, 2015, 11:56 AM
#5
Thread Starter
Member
Re: How to print documents
paul
I appreciate the suggestion, but I would use the resources of PrintDialog1
-
Mar 31st, 2015, 12:40 PM
#6
Re: How to print documents
You can use a printdocument, printdialog, and printpreviewdialog.
I'll see if i can find an example...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 31st, 2015, 12:47 PM
#7
Re: How to print documents
I don't have a lot of time to go into detail at the moment, but you use the printdialog to set the printdocument settings and the printpreviewdialog to preview.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|