|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Text on Image Resolutionit in the top left corner and a lot of empty canvas space to the right. I use about 10 text boxes on a form to populate that empty space with text. I then print the image ( from a picture box on my form) on a UPS Thermal Printer ( label printer) Problem is the resolution of the text is blurry. I tried changing the image resolution but that made it print very small. I dont know if I should try a differnt image type other then .png. The PC that prints the label is running XP. The below code is what creates the image and prints it: Private Sub btnMakeLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim imageName As String = "C:\Projects\Vitex\VPG_Small_3.png" Dim i As Image = Image.FromFile(imageName) Dim g As Graphics = Graphics.FromImage(i) Dim sf As StringFormat = CType(StringFormat.GenericTypographic.Clone(), StringFormat) sf.Alignment = StringAlignment.Center sf.LineAlignment = StringAlignment.Center Dim dt As Date = Date.Parse(Me.MonthCalendar1.SelectionRange.Start) Dim lblMonth As Integer = dt.Month Dim lblDay As Integer = dt.Day 'g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit g.DrawString(lblMonth.ToString() + " " + lblDay.ToString(), New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(65, 49, 50, 25), sf) 'g.DrawString("Set # ", New Font("Helvetica", 7, GraphicsUnit.Point), Brushes.Black, New RectangleF(50, 34, 50, 25), sf) g.DrawString(Me.txtSet.Text + "", New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(48, 49, 50, 25), sf) g.DrawString(Me.txtBackroll.Text, New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(38, 49, 50, 25), sf) g.DrawString("Op: " + Me.txtOperatorInitls.Text, New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(5, 50, 50, 25), sf) g.DrawString("Code: " + Me.txtCode.Text, New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(38, 2, 100, 25), sf) g.DrawString("SO: " + Me.txtS0.Text, New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(155, 1, 60, 25), sf) g.DrawString("Desc:" + Me.txtDescript1.Text, New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(40, 12, 120, 25), sf) g.DrawString(Me.txtDescript2.Text, New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(49, 22, 120, 25), sf) g.DrawString("PO: " + Me.txtPurchOrd.Text, New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(38, 34, 80, 25), sf) g.DrawString("Qty: " + Me.txtPressRepeats.Text, New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(127, 17, 90, 60), sf) g.DrawString("Roll # 1", New Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(107, 30, 120, 60), sf) g.Dispose() Me.PictureBox1.Image = i End Sub Private Sub btnPrintLabels_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Try 'If you do not specify a printer it uses the default 'Me.PrntDoc_Img.PrinterSettings.PrinterName = "Canon MF3110" Me.PrntDoc_Img.DocumentName = "Vitex Label" AddHandler PrntDoc_Img.PrintPage, AddressOf Me.pd_PrintPage PrntDoc_Img.Print() Catch ex As Exception MessageBox.Show("An error occurred while printing", _ ex.ToString()) End Try End Sub ' Specifies what happens when the PrintPage event is raised. Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs) ' Draw a picture. 'ev.Graphics. ev.Graphics.DrawImage(Me.PictureBox1.Image, _ ev.Graphics.VisibleClipBounds.Location) ' Indicate that this is the last page to print. ev.HasMorePages = False End Sub End Class Anything I can do to increase the text quality. Sounds like you're adding the text to the image and then printing the image.
You should probably send the image and then the text to the printer. The printer driver will then render the text at the full resolution of the printer. Show quoteHide quote "CG3000" <carlton_greg***@yahoo.com> wrote in message news:1142525526.536155.241730@u72g2000cwu.googlegroups.com... >I create a .PNG image ( in Macromedia Fireworks ) which has an gif in > it in the top left corner and a lot of empty canvas space to the right. > > > I use about 10 text boxes on a form to populate that empty space with > text. > > > I then print the image ( from a picture box on my form) on a UPS > Thermal Printer ( label printer) > > > Problem is the resolution of the text is blurry. > > > I tried changing the image resolution but that made it print very > small. > > > I dont know if I should try a differnt image type other then .png. > > > The PC that prints the label is running XP. The below code is what > creates the image and prints it: > Private Sub btnMakeLabel_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles Button1.Click > Dim imageName As String = "C:\Projects\Vitex\VPG_Small_3.png" > Dim i As Image = Image.FromFile(imageName) > Dim g As Graphics = Graphics.FromImage(i) > Dim sf As StringFormat = > CType(StringFormat.GenericTypographic.Clone(), StringFormat) > sf.Alignment = StringAlignment.Center > sf.LineAlignment = StringAlignment.Center > Dim dt As Date = > Date.Parse(Me.MonthCalendar1.SelectionRange.Start) > Dim lblMonth As Integer = dt.Month > Dim lblDay As Integer = dt.Day > 'g.TextRenderingHint = > Drawing.Text.TextRenderingHint.AntiAliasGridFit > g.DrawString(lblMonth.ToString() + " " + lblDay.ToString(), New > > Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New > RectangleF(65, 49, 50, 25), sf) > 'g.DrawString("Set # ", New Font("Helvetica", 7, > GraphicsUnit.Point), Brushes.Black, New RectangleF(50, 34, 50, 25), sf) > > g.DrawString(Me.txtSet.Text + "", New Font("Helvetica", 9, > GraphicsUnit.Pixel), Brushes.Black, New RectangleF(48, 49, 50, 25), sf) > > g.DrawString(Me.txtBackroll.Text, New Font("Helvetica", 9, > GraphicsUnit.Pixel), Brushes.Black, New RectangleF(38, 49, 50, 25), sf) > > g.DrawString("Op: " + Me.txtOperatorInitls.Text, New > Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New > RectangleF(5, 50, 50, 25), sf) > g.DrawString("Code: " + Me.txtCode.Text, New Font("Helvetica", > 9, GraphicsUnit.Pixel), Brushes.Black, New RectangleF(38, 2, 100, 25), > sf) > g.DrawString("SO: " + Me.txtS0.Text, New Font("Helvetica", 9, > GraphicsUnit.Pixel), Brushes.Black, New RectangleF(155, 1, 60, 25), sf) > > g.DrawString("Desc:" + Me.txtDescript1.Text, New > Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New > RectangleF(40, 12, 120, 25), sf) > g.DrawString(Me.txtDescript2.Text, New Font("Helvetica", 9, > GraphicsUnit.Pixel), Brushes.Black, New RectangleF(49, 22, 120, 25), > sf) > g.DrawString("PO: " + Me.txtPurchOrd.Text, New > Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New > RectangleF(38, 34, 80, 25), sf) > g.DrawString("Qty: " + Me.txtPressRepeats.Text, New > Font("Helvetica", 9, GraphicsUnit.Pixel), Brushes.Black, New > RectangleF(127, 17, 90, 60), sf) > g.DrawString("Roll # 1", New Font("Helvetica", 9, > GraphicsUnit.Pixel), Brushes.Black, New RectangleF(107, 30, 120, 60), > sf) > g.Dispose() > Me.PictureBox1.Image = i > End Sub > Private Sub btnPrintLabels_Click(ByVal sender As System.Object, ByVal e > > As System.EventArgs) Handles Button2.Click > Try > 'If you do not specify a printer it uses the default > 'Me.PrntDoc_Img.PrinterSettings.PrinterName = "Canon > MF3110" > Me.PrntDoc_Img.DocumentName = "Vitex Label" > AddHandler PrntDoc_Img.PrintPage, AddressOf Me.pd_PrintPage > > PrntDoc_Img.Print() > Catch ex As Exception > MessageBox.Show("An error occurred while printing", _ > ex.ToString()) > End Try > > > End Sub > ' Specifies what happens when the PrintPage event is raised. > Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As > System.Drawing.Printing.PrintPageEventArgs) > ' Draw a picture. > 'ev.Graphics. > ev.Graphics.DrawImage(Me.PictureBox1.Image, _ > ev.Graphics.VisibleClipBounds.Location) > > > ' Indicate that this is the last page to print. > ev.HasMorePages = False > End Sub > End Class > > > Anything I can do to increase the text quality. > I am adding the text to the image and then printing it.
How do you send the image and the text separate? Ill be honest and see I know how to print ONE document at a time. Not send a document in "pieces" I use VB6 and have only used dot net a couple of times (don't even have it
installed at work yet). But I would assume that after you send the image to the printer with: ev.Graphics.DrawImage(Me.PictureBox1.Image, ev.Graphics.VisibleClipBounds.Location) You could then send the text. ev.Graphics.DrawString(Me.txtSet.Text + "", New Font("Helvetica", 9,GraphicsUnit.Pixel), Brushes.Black, New RectangleF(48, 49, 50, 25), sf) You will probably need to adjust the sizes of the font, and the rectangle as you are now working with the printer units, not the image units. I think in VB6 by default each inch = 1440 pixels... not sure what it is in dot net. Hopefully this will point you in the right direction as I can't test it here. Show quoteHide quote "CG3000" <carlton_greg***@yahoo.com> wrote in message news:1142545941.688599.176610@z34g2000cwc.googlegroups.com... >I am adding the text to the image and then printing it. > > How do you send the image and the text separate? > > Ill be honest and see I know how to print ONE document at a time. Not > send a document in "pieces" > Enfor thank you. I think you are right.
I did what you said in a small test and it worked. I dont understand GDI+ to a greath depth but I read this has something to do with the text resolution being separate from the PCs resolution. Ill let you know after I add all my text box values. I initially tried one text box value and I saw a HUGE diff in the resolution.
Reading Stream After RedirectStandardOutput=True Blocks
I can't find the error here.... Serial Date Stored procedure handling 1 parent record and multiple child recor Confusion on Protected Overrides Loop through columns of all datarows in a dataset my form cannot from from network checking for EOF DataGridView validation to underlying DataSource Problems using HasMorePages with oleDbDatareader |
|||||||||||||||||||||||