Hi, I want to print an image through an IPI Thermal Printer.
What I have tried:
I used a canvas control to arrange the information that i want printed on the paper and i captured the canvas control and converted to an image source using the code below
Canvas ck = new Canvas();
Rect rect = new Rect(canvas.RenderSize);
RenderTargetBitmap rtb = new RenderTargetBitmap((int)canvas.RenderSize.Width * 2, (int)canvas.RenderSize.Height * 2, 96d, 96d, System.Windows.Media.PixelFormats.Default);
rtb.Render(canvas);
BitmapEncoder pngEncoder = new PngBitmapEncoder();
pngEncoder.Frames.Add(BitmapFrame.Create(rtb));
System.IO.MemoryStream ms = new System.IO.MemoryStream();
pngEncoder.Save(ms);
var imageSource = new BitmapImage();
imageSource.BeginInit();
imageSource.StreamSource = ms;
imageSource.EndInit();
i instantiated the printdialog and passed the image to it using the following code
System.Windows.Controls.PrintDialog dlg = new System.Windows.Controls.PrintDialog();
if (dlg.ShowDialog() == true)
{
System.Windows.Size printSize = new
System.Windows.Size(dlg.PrintableAreaWidth, dlg.PrintableAreaHeight);
System.Windows.Controls.Image img = new System.Windows.Controls.Image();
img.Source = imageSource;
img.Stretch = Stretch.UniformToFill;
img.Margin = new Thickness(48);
dlg.PrintVisual(img, "Account Opening Details");
}
this opens the printdialog box but does not start the printer after i click print. like the printer does not spool or run. I printed a test page on the printer and it worked. It printed fine. So i instantiated a print document like this
PrintDocument dd = new PrintDocument();
but how do i pass the image to the print document before calling the
dd.Print()
function?