Quick Print Option

SyntaxEditor for WPF Forum

Posted 10 years ago by Jonathan Terrell
Version: 9.1.0505
Avatar
Hi, do you have an example of a quick print option. The SyntaxEditor.ShowPrintDialog always displays a dialog, is it possible to print without displaying the dialog. Any assistance appreciated.

Comments (3)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jonathan,

You'd first get a FixedDocument like this:
FixedDocument fixedDocument = editor.PrintSettings.CreateFixedDocument(editor);
Then you could probably make a PrintDialog and use it to print without showing anything:
PrintDialog window = new PrintDialog();
window.PrintDocument(fixedDocument.DocumentPaginator, editor.Document.FileName);


Actipro Software Support

Posted 10 years ago by Jonathan Terrell
Avatar
Hi, appreciate the feedback. This is exactly what I was looking for. I have been able to implement with one minor issue. When printed the page numbers at the bottom of the first page show as "Page 1 of 0" and subsequent pages as "Page 0 of 0". Is there a quick solution to this or do I have to implement a custom DocumentPaginator. If the custom DocumentPaginator is required, any clues on how I located and modify these values. Appreciate the help
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jonathan,

Hmm, those values come from bindings in the template for that line number margin. They search up for a parent IPrinterView and grab the PageNumber and PageCount from that. The weird thing is that I can step through and see the printer views being created properly. But for some reason actually displaying the Print dialog makes a difference as to whether these bindings function or not. So far I'm not sure what is causing that. I don't think the document paginator has anything to do with it though.

Another option is to export an XPS like in our other quickstart and just send that to your printer.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.