Printing Questions

Technical support for Spire.DocViewer

Moderator: iceblue support

Printing Questions

Postby skelsey » Thu May 09, 2013 8:39 pm

I am looking for a way to print a document that has been created without saving it. Can this bee done with Spire? See code block below. Don't want to have to save and load file to print.

Private Sub btnSpire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpire.Click

Dim dt As Orders.OrderDataDataTable
Dim dr As Orders.OrderDataRow
Dim da As New OrdersTableAdapters.OrderDataTableAdapter
Dim i As Integer

dt = da.GetOrderData()

For i = 0 To dt.Rows.Count - 1
dr = dt.Rows(i)
Dim testDoc As New Document()

addHeader(dr, testDoc)
addStaticRowHeader(testDoc)
insertpic(dr.SMALL_IMAGE, testDoc)
testDoc.SaveToFile(My.Application.Info.DirectoryPath & "\" & i.ToString() & "TEST.doc", FileFormat.Doc)
dv.LoadFromFile(My.Application.Info.DirectoryPath & "\" & i.ToString() & "TEST.doc")

PrintME(My.Application.Info.DirectoryPath & "\" & i.ToString() & "TEST.doc")
Next i

Debug.WriteLine(Now.ToString())


End Sub

Also if you save the document is there a way to print multiple document without showing the print dialog screen for confirmation? if i have ten documents I want all ten to print. the user doesn't need to change or select options because the document is custom.

Private Sub PrintME(ByVal tmpDoc As String)
Dim dialog As New PrintDialog()
Dim result As DialogResult = dialog.ShowDialog()

dialog.AllowCurrentPage = True
dialog.AllowSomePages = True
dialog.UseEXDialog = True

If result = DialogResult.OK Then
Try

dv.PrintDialog = dialog
dialog.Document = dv.PrintDocument
dv.PrintDocument.DefaultPageSettings.Landscape = True
dialog.Document.Print()

Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

End If

End Sub
skelsey
 
Posts: 10
Joined: Mon May 06, 2013 1:54 pm

Re: Printing Questions

Postby Gary.zhang » Fri May 10, 2013 9:09 am

Hello skelsey,

Thanks for your inquiry.

In regards to your issue, please refer to the code below,

Code: Select all
Private Sub Print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Print.Click
        Dim document As New Document()
        Dim section As Section = document.AddSection()
        section.PageSetup.PageSize = PageSize.A4
        section.PageSetup.Margins.Top = 72.0F
        section.PageSetup.Margins.Bottom = 72.0F
        section.PageSetup.Margins.Left = 89.85F
        section.PageSetup.Margins.Right = 89.85F
        Dim paragraph As Paragraph = section.AddParagraph()
        paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Left
        Dim p1 As String = "Microsoft Word is a word processor designed by Microsoft. " & "It was first released in 1983 under the name Multi-Tool Word for Xenix systems. " & "Subsequent versions were later written for several other platforms including " & "IBM PCs running DOS (1983), the Apple Macintosh (1984), the AT&T Unix PC (1985), " & "Atari ST (1986), SCO UNIX, OS/2, and Microsoft Windows (1989). "
        Dim p2 As String = "Microsoft Office Word instead of merely Microsoft Word. " & "The 2010 version appears to be branded as Microsoft Word, " & "once again. The current versions are Microsoft Word 2010 for Windows and 2008 for Mac."
        section.AddParagraph().AppendText(p1).CharacterFormat.FontSize = 14
        section.AddParagraph().AppendText(p2).CharacterFormat.FontSize = 14
        'Print
        Dim dialog As New PrintDialog()
        dialog.AllowCurrentPage = True
        dialog.AllowSomePages = True
        dialog.UseEXDialog = True
        Try
            document.PrintDialog = dialog
            dialog.Document = document.PrintDocument
            dialog.Document.PrintController = New StandardPrintController()         
            dialog.Document.Print()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub


If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1345
Joined: Thu Apr 04, 2013 1:30 am

Re: Printing Questions

Postby skelsey » Fri May 10, 2013 1:08 pm

Hi Gary,

thanks for getting back to me so quickly. I have put the code changes that you suggest, but I get an error that the
PrintDialog is not a member of the Spire.Doc.Document &
PrintDocument is not a member of the Spire.Doc.Document

Sophia
skelsey
 
Posts: 10
Joined: Mon May 06, 2013 1:54 pm

Re: Printing Questions

Postby Gary.zhang » Mon May 13, 2013 2:22 am

Hi Sophia,

Sorry for inconvenience.

They exist in the Spire.Doc Version 4.8, please download it from http://www.e-iceblue.com/Download/download-word-for-net-now.html and try again.

If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1345
Joined: Thu Apr 04, 2013 1:30 am

Re: Printing Questions

Postby Gary.zhang » Tue May 14, 2013 9:59 am

Hi Sophia,

Has the issue been resolved? Could you please update the thread if convenience?

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1345
Joined: Thu Apr 04, 2013 1:30 am

Re: Printing Questions

Postby skelsey » Tue May 14, 2013 12:55 pm

Hi Gary,

Thank you...The problem has been resolved. The new version works fine.

Thanks,
Sophia
skelsey
 
Posts: 10
Joined: Mon May 06, 2013 1:54 pm


Return to Spire.DocViewer

Who is online

Users browsing this forum: No registered users and 0 guests