2015-10-30 46 views
0

我最近將計算機升級到了Windows 10,現在其中一個程序在升級後表現怪異。 試圖從PDF打印頁面範圍,並且當我打印第1頁到第100頁時(477頁中出現),即使100小於477,我也會收到錯誤消息ToPage should be less than the page count
如果我跳過頁面範圍部分只要打印所有的頁面,它就可以正常工作。錯誤的PrintDialog ToPage應小於頁數

Sub PrintToPaperSync(ByVal InputfilePath As String, Optional ByVal DeleteAfter As Boolean = False) 
    On Error GoTo sError 

    Dim tError As String = "" 
    Dim toPage As Integer = 0 

    Console.WriteLine("PrintToPaper " & InputfilePath) 
    Dim File As String = Split(InputfilePath, "\")(Split(InputfilePath, "\").Length - 1) 
    Dim viewer As New Syncfusion.Windows.Forms.PdfViewer.PdfDocumentView 
    viewer.Load(InputfilePath) 
    Dim print As New System.Windows.Forms.PrintDialog() 

    print.Document = viewer.PrintDocument 
    print.Document.DocumentName = File 

    'print 100 pages at a time 
    Do While toPage < viewer.PageCount 
     print.Document.PrinterSettings.PrintRange = Drawing.Printing.PrintRange.SomePages 
     print.Document.PrinterSettings.FromPage = toPage + 1 
     toPage += 100 
     print.Document.PrinterSettings.ToPage = IIf(toPage < viewer.PageCount, toPage, viewer.PageCount) 

     tError = "From: " & print.Document.PrinterSettings.FromPage & " | To: " & print.Document.PrinterSettings.ToPage & " | PageCount: " & viewer.PageCount & " - " 
     print.Document.Print() 

     Application.DoEvents() 
    Loop 

    viewer.Unload() 
    viewer.Dispose() 

    Console.WriteLine("Printing: " & InputfilePath) 

    Exit Sub 
sError: 
    Dim ErrorStr As String = ErrorToString() 
    WriteLine("PrintToPaper " & tError & " " & InputfilePath & " - " & ErrorStr) 
End Sub 

全文:
PrintToPaper From: 1 | To: 100 | PageCount: 477 - F:\Process\LogTag-10-30-15-104122.pdf - ToPage should be less than the page count

我們希望只打印在一個時間100頁,因爲打印機開始後100頁出於某種原因放緩。

+1

爲了測試我建議你將它轉換爲一個try catch塊,並打印出你得到真正的例外 - 它可能會很長的路要走找出你的問題是什麼。 – Rob

回答

1

此打印問題是由於Syncfusion控件的問題引起的。您可以聯繫Syncfusion軟件支持團隊以解決問題。請按照下面的鏈接聯繫Syncfusion支持團隊

Click Here