[img]https://i.sstatic.net /gYibbFJI.png[/img]
ниже приведен код для открытия диалогового окна печати с помощью xps
Код: Выделить всё
public void PrintXps()
{
FlowDocument doc = new FlowDocument(new Paragraph(new Run("Hello, this is a sample document.")));
doc.PagePadding = new Thickness(50);
doc.PageWidth = 800;
doc.PageHeight = 600;
string tempXpsFilePath = Path.GetTempFileName() + ".xps";
try
{
using (var xpsDocument = new XpsDocument(tempXpsFilePath, FileAccess.ReadWrite))
{
var xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDocument);
DocumentPaginator paginator = ((IDocumentPaginatorSource)doc).DocumentPaginator;
xpsWriter.Write(paginator);
}
var xpsDoc = new XpsDocument(tempXpsFilePath, FileAccess.Read);
FixedDocumentSequence fixedDocSeq = xpsDoc.GetFixedDocumentSequence();
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() == true)
{
printDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Printing XPS Document");
}
xpsDoc.Close();
}
finally
{
File.Delete(tempXpsFilePath);
}
}
Заранее спасибо!
Подробнее здесь: https://stackoverflow.com/questions/790 ... df-preview