Hi Imports System.Drawing.Imaging Imports System.Drawing.Printing Private Sub PrintDocument1_PrintPage(ByVal Sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Static page As Integer = 1 Dim startPosition As Integer = (page - 1) * PrintDocument1.DefaultPageSettings.Bounds.Height Static maxPages As Integer = 0 If page = 1 Then For Each ctrl As Control In Me.pRight19.Controls If TypeOf ctrl Is TextBox Or TypeOf ctrl Is Label Or TypeOf ctrl Is PictureBox Or TypeOf ctrl Is RichTextBox Then ctrl.Tag = Int((ctrl.Top + ctrl.Height) / PrintDocument1.DefaultPageSettings.Bounds.Height) + 1 If CInt(ctrl.Tag) > maxPages Then maxPages = CInt(ctrl.Tag) End If Next End If For Each ctrl As Control In Me.pRight19.Controls If CInt(ctrl.Tag) = page Then If TypeOf ctrl Is TextBox Or TypeOf ctrl Is Label Or TypeOf ctrl Is RichTextBox Then Dim sf As New System.Drawing.StringFormat If TypeOf ctrl Is TextBox Then If DirectCast(ctrl, TextBox).TextAlign = HorizontalAlignment.Right Then sf.Alignment = StringAlignment.Far Else sf.Alignment = StringAlignment.Near End If ElseIf TypeOf ctrl Is Label Then If DirectCast(ctrl, Label).TextAlign = ContentAlignment.TopLeft Then sf.Alignment = StringAlignment.Far End If ElseIf TypeOf ctrl Is RichTextBox Then If DirectCast(ctrl, RichTextBox).SelectionAlignment = ContentAlignment.TopLeft Then sf.Alignment = StringAlignment.Near End If End If sf.FormatFlags = StringFormatFlags.NoClip e.Graphics.DrawString(ctrl.Text, ctrl.Font, New SolidBrush(ctrl.ForeColor), New Rectangle(ctrl.Left, ctrl.Top - startPosition, ctrl.Width + 50, ctrl.Height), sf) ElseIf TypeOf ctrl Is PictureBox Then e.Graphics.DrawImage(DirectCast(ctrl, PictureBox).Image, New PointF(ctrl.Left, ctrl.Top - startPosition)) End If End If Next page += 1
drago11
Posts
-
Create Image from Panel Control -
tif img print previewThanks Dave, Eddy Do you have any ideas how I can do that...
-
tif img print previewVb net 2010 Tif img I would like to print that image by calling print preview Image is larger than one print page. I cannot get another (second) page where it should be rest of that img. I'm using Img.framecount(framedimension .page) where count is always 1, but should be 2. (To divide 1 tiff img to 2 print pages) Thanks Imports System.Drawing.Printing Imports System.Drawing.Imaging Imports System.Drawing Imports System.IO Public Class Form2 Private fileCount As Integer = 0 Private currPage As Integer = 0 Private pCount As Integer = 0 Private currImage As Image Private Sub vPrintDocument() Dim vPrintDoc As New PrintDocument vPrintDoc.DefaultPageSettings.Landscape = False AddHandler vPrintDoc.PrintPage, AddressOf docPrintPage AddHandler vPrintDoc.BeginPrint, AddressOf docBeginPrint Dim i As PrintPreviewDialog = New PrintPreviewDialog i.Document = vPrintDoc i.ShowDialog() End Sub Private Sub docBeginPrint(ByVal sender As Object, ByVal e As PrintEventArgs) currPage = 0 currImage = Image.FromFile("C:\out.tif") pCount = currImage.GetFrameCount(Imaging.FrameDimension.Page) ‘MsgBox(pCount) End Sub Private Sub docPrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) currImage.SelectActiveFrame(Imaging.FrameDimension.Page, currPage) e.Graphics.DrawImage(currImage, 20, 20) currPage = currPage + 1 If currPage < pCount Then e.HasMorePages = True Else e.HasMorePages = False End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call vPrintDocument() End Sub End Class
-
tif img print previewGood day, I have a tiff img (img is including pic and text ) Tiff is bigger than 1print page, so I assuming when I call framecount should put 2 pages, but not, always show 1p Page is not completed it showes2/3 1/3 it should go to other page but doesn't show. Sorry I read most of codes what people wrote, but they are not working for me. If somebody can help will be greatefull Regards Drago