I am trying to print some .png files directly to the printer.
Therefore I set up this function:
private void Print(string filepath)
{
LocalPrintServer printServer = new LocalPrintServer();
PrintQueue printQueue = printServer.GetPrintQueue("PDFCreator");
BitmapImage image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad;
image.UriSource = new Uri(filepath);
image.EndInit();
PrintDialog printDialog = new PrintDialog
{
PrintQueue = printQueue
};
DrawingVisual visual = new DrawingVisual();
var dc = visual.RenderOpen();
dc.DrawImage(image, new System.Windows.Rect { Width = image.Width, Height = image.Height });
printDialog.PrintVisual(visual, filepath);
}
The printing itself works properly but it is just printing an blank piece of paper.