2009-06-08 5 views

답변

6

PrintForm 구성 요소를 사용해야합니다. How to: Print a Form by Using the PrintForm Component를 참조하십시오

을 PrintForm 구성 요소는 빨리가하는 PrintDocument 구성 요소를 사용하지 않고 화면 에 표시된대로 정확하게 형태 의 이미지를 인쇄 할 수 있습니다. 다음 절차 은 양식을 프린터로 인쇄하는 방법, 을 인쇄 미리보기 창, 캡슐화 된 포스트 스크립트 파일로 보여줍니다.

0

양식의 스냅 샷을 원한다면 화면 캡처를 시뮬레이트해야합니다. 도움이 될 sample입니다. 꽤 못 생겨서 PDF 또는 보고서 빌더를 사용하여 보고서를 작성하는 것이 좋습니다.

+0

가 새 구성 요소를 Theres는합니다 (Button1을 클릭에) 다음 코드는 비트 맵을 캡처하고 프린터로 전송합니다 이미지를 수정하십시오. –

+0

허, 잘 몰라. 멋지다, tnx. :) – jvenema

3

당신이

Imports System.Drawing.Printing 

Public Class Form1 

Dim WithEvents mPrintDocument As New PrintDocument 
Dim mPrintBitMap As Bitmap 


Private Sub m_PrintDocument_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles mPrintDocument.PrintPage 
    ' Draw the image centered. 
    Dim lWidth As Integer = e.MarginBounds.X + (e.MarginBounds.Width - mPrintBitMap.Width) \ 2 
    Dim lHeight As Integer = e.MarginBounds.Y + (e.MarginBounds.Height - mPrintBitMap.Height) \ 2 
    e.Graphics.DrawImage(mPrintBitMap, lWidth, lheight) 

    ' There's only one page. 
    e.HasMorePages = False 
End Sub 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    ' Copy the form's image into a bitmap. 
    mPrintBitMap = New Bitmap(Me.Width, Me.Width) 
    Dim lRect As System.Drawing.Rectangle 
    lRect.Width = Me.Width 
    lRect.Height = Me.Width 
    Me.DrawToBitmap(mPrintBitMap, lRect) 


    ' Make a PrintDocument and print. 
    mPrintDocument = New PrintDocument 
    mPrintDocument.Print() 
End Sub 
End Class 
+0

이것은 좋지만 용지 크기를 고려하지 않았습니다. – jcaruso

관련 문제