Hello,
We are facing this strange issue with PDFViewer.Print functionality on Windows 10 only.
Attached is the sample using latest Telerik dlls (Telerik_UI_for_WPF_2015_2_728_Dev.msi). The problem is - once we print - it goes into the Printing queue and shows "Spooling" but does not print - rather disappears after some time. Please advise.
class
Program
{
/// <summary>
/// Main method.
/// </summary>
/// <param name="args">The args.</param>
[STAThread]
static
void
Main(
string
[] args)
{
string
fileName =
"CMI9063.pdf"
;
if
((args !=
null
) && (args.Length > 0))
{
fileName = args[0];
}
// Load the PDF file.
byte
[] buffer = LoadPdfFile(fileName) ??
new
byte
[] { };
using
(MemoryStream stream =
new
MemoryStream(buffer))
{
PrintDialog printDialog =
new
PrintDialog { UserPageRangeEnabled =
true
};
if
(printDialog.ShowDialog() ==
true
)
{
RadPdfViewer radPdfViewer =
new
RadPdfViewer { DefaultFormatProviderSettings = FormatProviderSettings.ReadOnDemand };
radPdfViewer.ClearDocument();
radPdfViewer.Document =
new
PdfFormatProvider(stream, FormatProviderSettings.ReadOnDemand).Import();
radPdfViewer.Print(printDialog, PrintSettings.Default);
//System.Windows.MessageBox.Show("Successfully print to \"" + printDialog.PrintQueue.FullName + "\"", "Print", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
}
}
}
private
static
byte
[] LoadPdfFile(
string
filePath)
{
byte
[] buffer;
string
folder = Directory.GetCurrentDirectory();
if
(!filePath.StartsWith(folder))
{
filePath = Path.Combine(folder, filePath);
}
//load from physical path
if
(File.Exists(filePath))
{
using
(FileStream fs =
new
FileStream(filePath, FileMode.Open))
{
buffer =
new
byte
[fs.Length];
fs.Read(buffer, 0, buffer.Length);
}
}
else
{
return
null
;
}
return
buffer;
}
}