Spire.DocViewer for .NET is a powerful Word Viewer component for developers to display, convert and interact with Word Documents easily.

Tue Jul 24, 2018 1:38 pm

Hello,
can I wait for DocDocumentViewer to load document from file? I'm working on these three steps to programmatically print with/withnout user interaction:

1) Programmatically load document:
Code: Select all
this.docDocumentViewer.LoadFromFile("tmp.docx");


2) Wait until document is loaded, or fire event when it's loaded.


3) Programmatically print document:
Code: Select all
this.customizeToolBar.DialogPrint();
this.customizeToolBar.SilentPrint();


Also I'd like to hide form and show only print dialog.

Thanks for any hints.

f00bar
 
Posts: 5
Joined: Mon Jul 16, 2018 8:34 am

Wed Jul 25, 2018 10:19 am

Hi f00bar,

Thanks for your post.
Spire.DocViewer has provided a document loaded event "DocLoaded". You could do the printing in this event to accomplish your task. In addition, the property "Visible " is for hiding the viewer form. Please refer to the code below.
Code: Select all
private void button1_Click(object sender, EventArgs e)
{
    //Hide the viewer form
    this.docDocumentViewer1.Visible = false;
    //Load file
    this.docDocumentViewer1.LoadFromFile("tmp.docx");
    //Print in the DocLoaed event
    this.docDocumentViewer1.DocLoaded += docDocumentViewer1_DocLoaded;
}

private void docDocumentViewer1_DocLoaded(object sender, EventArgs args)
{
    //MessageBox.Show("File Loaded!");
    //Silent print
    this.docDocumentViewer1.PrintDocument.PrintController = new StandardPrintController();
    this.docDocumentViewer1.PrintDocument.Print();
}
Sincerely,
Hogan
E-iceblue support team
User avatar

hogan.tang
 
Posts: 51
Joined: Tue Jul 03, 2018 1:43 am

Wed Jul 25, 2018 12:55 pm

Hi,
thanks a lot for solution, this works really great :)

f00bar
 
Posts: 5
Joined: Mon Jul 16, 2018 8:34 am

Thu Jul 26, 2018 4:04 am

Dear f00bar,

Thanks for your feedback.
Please feel free to contact us if you encounter any problem.
Have a nice day!
Sincerely,
Hogan
E-iceblue support team
User avatar

hogan.tang
 
Posts: 51
Joined: Tue Jul 03, 2018 1:43 am

Return to Spire.DocViewer