Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15685

VS 2013 How to define Centimeters unit in printdocument

$
0
0
Hello everyone,

I am designing a cheque printing software, different banks have different cheque dimensions, so I created a form and asked for each field location both x & y in pixels, my client set 1st bank cheque accurately by placing x & y values, but when he open the same form on another computer whose computer resolution is different the whole setting lost. basically setting of pixels depend on screen resolution, if 2 computers have different resolutions the placing of fields will be different.

Here is my code, please provide me some solution to give x & y values in cms not in pixels.

Thank you
Ladak

Code:


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

     

        '' Number Format
        Dim Numformat As StringFormat = New StringFormat
        Numformat.Alignment = StringAlignment.Near
        Numformat.LineAlignment = StringAlignment.Center
        Numformat.FormatFlags = StringFormatFlags.NoWrap

        ' Text Format
        Dim TextFormat As New System.Drawing.StringFormat
        TextFormat.LineAlignment = StringAlignment.Near  ' .Center ' .Near    ' center horizontally
        TextFormat.Alignment = StringAlignment.Near  ' center vertically
        TextFormat.Trimming = StringTrimming.Word
        'TextFormat.FormatFlags = StringFormatFlags.NoWrap


        Dim SdsFont As Font = New Font("Tahoma", 8, FontStyle.Regular)

        ' Counter Side

        Dim rectF1 As New RectangleF

        If ChkPrintCounter.Checked = True Then

            rectF1 = New RectangleF(Val(txtCounterDateX.Text), Val(txtCounterDateY.Text), 100, 50)
            e.Graphics.DrawString(lblChequeDate.Text, SdsFont, Brushes.Black, rectF1, TextFormat)

            rectF1 = New RectangleF(Val(txtCounterPayX.Text), Val(txtCounterPayY.Text), 100, 50)
            e.Graphics.DrawString(txtPayTo.Text, SdsFont, Brushes.Black, rectF1, TextFormat)


            rectF1 = New RectangleF(Val(txtCounterAmountX.Text), Val(txtCounterAmountY.Text), 100, 50)
            e.Graphics.DrawString(lblChequeAmount.Text, SdsFont, Brushes.Black, rectF1, Numformat)

        End If

        '
        ' End of Counter



        ' Main Side
        rectF1 = New RectangleF(Val(txtMainDateX.Text), Val(txtMainDateY.Text), 100, 50)
        e.Graphics.DrawString(lblChequeDate.Text, SdsFont, Brushes.Black, rectF1, TextFormat)


        rectF1 = New RectangleF(Val(txtMainPayX.Text), Val(txtMainPayY.Text), 500, 50)
        e.Graphics.DrawString(txtPayTo.Text, SdsFont, Brushes.Black, rectF1, TextFormat)


        rectF1 = New RectangleF(Val(txtMainRupeesX.Text), Val(txtMainRupeesY.Text), 100, 50)
        e.Graphics.DrawString("=" & lblChequeAmount.Text, SdsFont, Brushes.Black, rectF1, Numformat)


        rectF1 = New RectangleF(Val(txtMainRupeesInWordsX.Text), Val(txtMainRupeesInWordsY.Text), 375, 50)
        e.Graphics.DrawString(lblChequeAmountInWords.Text, SdsFont, Brushes.Black, rectF1, TextFormat)


        ' End of Main Side

        Dim X1 As Integer = Val(txtCrossX.Text)
        Dim Y1 As Integer = Val(txtCrossY.Text)

        If ChkCrossCheque.Checked = True Then
            'e.Graphics.DrawImage(PictureBox1.Image, e.MarginBounds.Left, e.MarginBounds.Top, 100, 25)
            e.Graphics.DrawImage(PictureBox1.Image, X1, Y1, 100, 25)
        End If





    End Sub


Viewing all articles
Browse latest Browse all 15685

Trending Articles