sBarcode()

sBarcode(int hDpi, int vDpi) generates an image scaled to be suitable for printing on a device with horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively.

Return Type:  Metafile

sBarcode(Graphics g, int hDpi, int vDpi)     generates an image scaled to be suitable for printing on a device with horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively using the properties of Graphics g.  If hDpi and vDpi are zero the properties of the Graphics g will be used.

Return Type:  Metafile

sBarcode(int hDpi, int vDpi, ImageFormat im)      generates an memory stream image with the format specified by im, scaled to be suitable for printing on a device with horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively with the bars pixel aligned.

sBarcode(int hDpi, int vDpi, ImageFormat im, int iPixAlign) If iPixAlign is 1 and the image format specifies a bitmap format, then the image is resized so that the bars are pixel aligned. If iPixAlign is 0 does the bitmap is created without pixel alignment.

 

Return Type:  MemoryStream. Returns a MemoryStream of Length 0 if an error occurs.

sBarcode(int hDpi, int vDpi, string filename)         saves an image into the file specified by filename with the format specified by filename extension, scaled to be suitable for printing on a device with horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively with the bars pixel aligned.

sBarcode(int hDpi, int vDpi, string filename, int iPixAlign)  If iPixAlign is 1 and the graphics file name specifies a bitmap format, then the image is resized so that the bars are pixel aligned. If iPixAlign is 0 does the bitmap is created without pixel alignment.

Return Type:  Int. Returns 0 if successful or 1 if an error occurs.

These methods are useful for generating an image that is to be saved for later printing, e.g. for saving an image that will be subsequently printed on a 600 dpi printer:

Filename=”c:\fred.png”
Abcnet1.sBarcode(600,600, filename)

Saves the file and the following print handler print the image

    Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

        Dim newImage As Image = Image.FromFile(graphicfilename)
        Dim r As Rectangle
        r.X = 600
        r.Y = 600
        r.Width = newImage.Width
        r.Height = newImage.Height
        e.Graphics.PageUnit = GraphicsUnit.Pixel '
        e.Graphics.DrawImage(newImage, r)
        ' Indicate that this is the last page to print.
        e.HasMorePages = False

    End Sub

If hDpi and vDpi are zero the properties of the Graphics g will be used.

 

More:

GS1 Encoding