Generates a preview image of the label.

Namespace:  DYMO.Label.Framework
Assembly:  DYMO.Label.Framework (in DYMO.Label.Framework.dll) Version: 1.0.0.0 (8.4.0.1475)

Syntax

C#
byte[] RenderAsPng(
	IPrinter printer,
	ILabelRenderParams renderParams
)
Visual Basic (Declaration)
Function RenderAsPng ( _
	printer As IPrinter, _
	renderParams As ILabelRenderParams _
) As Byte()
Visual C++
array<unsigned char>^ RenderAsPng(
	IPrinter^ printer, 
	ILabelRenderParams^ renderParams
)

Parameters

printer
Type: DYMO.Label.Framework..::.IPrinter
Printer characteristics used to render the label preview.
renderParams
Type: DYMO.Label.Framework..::.ILabelRenderParams
Rendering parameters.

Return Value

Byte-array of base64-encoded PNG stream.

Remarks

This method can be used to display a label preview in an application. Specify the same IPrinter instance in printer parameter as will later be used to print the label. It is important that these match because certain printer characteristics, such as printer resolution, printable area, and so on, are used to generate the label preview. Specifying different printers can result in an inaccurate preview. If null is specified for printer, the first available printer the label can be printed to will be used to get the nessesary characteristics. If there is no such printer installed, the default characteristics will be used.

Examples

The following example demonstrates how to create a label preview image and save to the image to a file.
CopyC#
void RenderAsPng()
{
    // obtain a reference to ILabel by loading a label from a file
    ILabel label = Label.Open("MyLabel.label");

    // render using default printer and default parameters
    byte[] pngData = label.RenderAsPng(null, null);

    // save to file
    System.Drawing.Image.FromStream(new MemoryStream(pngData)).Save("MyLabelImage.png");
}

See Also