This is a migrated thread and some comments may be shown as answers.

Index out of range when Printing current Page

10 Answers 868 Views
PdfViewer and PdfViewerNavigator
This is a migrated thread and some comments may be shown as answers.
willi
Top achievements
Rank 1
willi asked on 03 Apr 2014, 07:45 AM
Hi!

I'm using the following code to Print a PDF-Document from an Viewer with an external Button:

1.Public Shared Sub printPdf(newPdfViewerNavigator As RadPdfViewerNavigator, newPdfViewer As RadPdfViewer, Optional landscape As Boolean = False, Optional silent As Boolean = False)
2.    newPdfViewerNavigator.PrintDocument.DefaultPageSettings.Margins = New System.Drawing.Printing.Margins(0, 0, 0, 0)
3.    newPdfViewerNavigator.PrintDocument.Landscape = landscape
4.    newPdfViewer.Print(True, newPdfViewerNavigator.PrintDocument)
5.End Sub

The main Problem is when selecting only the current page to print, an "index out of range" error occoured in line 4. Printing an selected Range (page 1-2, page2...) is working.

I'm using Version 2013.1.321.40

The second Problem is, that the print-button on the Printer-settings page has to be clicked twice to start printing. It looks like, that the first click focuses the form and the second initiates the click event...

Please help.

Best
Willi

10 Answers, 1 is accepted

Sort by
0
willi
Top achievements
Rank 1
answered on 03 Apr 2014, 08:33 AM
Update: 
Same in Version: 2014.1.226.40
0
George
Telerik team
answered on 08 Apr 2014, 08:19 AM
Hi Wilfrid,

Thank you for contacting us.

I was not able to reproduce this behavior on my end. Could you please provide me with a sample where the problem is reproducible ? I think that the issue may come from the specific PDF document, so please make sure to attach it also.

Moreover, it appeared that the Print button in the print settings was working fine, please provide me with detailed instructions on this matter too.

Looking forward to your response.

Regards,
George
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
willi
Top achievements
Rank 1
answered on 10 Apr 2014, 07:20 AM
So, as its not possible to attach an zip here, her you can download the Demosolution

https://dl.dropboxusercontent.com/u/24065/TelerikDemo.zip

Reproducing the error with the crash:
1. Running the Solution (When running the Programm a Window with the PDF-Viewer opens and a PDF is loaded. )
2. Press the Print Button on the right hand side
3. In the Printer-Dialog select only printinaag the current Page
4. Press Print - Programm crashes

Reproducing the Focusing problem
Step 1,2 from above
3. Imidiatly press the Print Button (without clicking on the printerform) - Nothing happens - 
4. "Press" button again the printing will be started

best
Willi














0
George
Telerik team
answered on 15 Apr 2014, 09:07 AM
Hello Wilfrid,

Thank you for contacting us.

I have identified the exception. The issue is logged in our Feedback Portal and can be found on the following url: http://feedback.telerik.com/Project/154/Feedback/Details/125972-fix-radpdfviewer-printing-by-calling-the-print-method-of-radpdfviewer-and-sele. For the time being due to the implementation of the printing mechanism the issue cannot be directly worked around. You can however, instead of selecting the CurrentPage to select the Pages button and specify the page to be printed.

I have also logged your other report - http://feedback.telerik.com/Project/154/Feedback/Details/125981-fix-radpdfviewer-openning-the-printdialog-using-the-print-method-causes-the-di. Currently, this issue has no workaround since the dialog is a standard WinForms PrintDialog.

I have updated your Telerik Points for bringing this to our attention. 

Let me know if you have further questions.

Regards,
George
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Matthias
Top achievements
Rank 1
answered on 29 Apr 2014, 07:25 AM
Hey,
i use this workaround:

private void button2_Click(object sender, EventArgs e)
{
        RadPrintDocument document = new RadPrintDocument();
        document.BeginPrint += document_BeginPrint;
        radPdfViewer1.Print(true,document);
}

void document_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
                if(((System.Drawing.Printing.PrintDocument)(sender)).PrinterSettings.FromPage==0 &&((System.Drawing.Printing.PrintDocument)(sender)).PrinterSettings.ToPage==0){
               //Fix da aktuelle Seite nicht geht
                ((System.Drawing.Printing.PrintDocument)(sender)).PrinterSettings.FromPage = int.Parse(this.radPdfViewerNavigator1.CurrentPageTextBox.Text);
                ((System.Drawing.Printing.PrintDocument)(sender)).PrinterSettings.ToPage = int.Parse(this.radPdfViewerNavigator1.CurrentPageTextBox.Text);
                ((System.Drawing.Printing.PrintDocument)(sender)).PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.SomePages;
        }
}
0
willi
Top achievements
Rank 1
answered on 29 Apr 2014, 08:11 AM
Thanks Matthias, its working like a charm...
0
George
Telerik team
answered on 30 Apr 2014, 08:27 AM
Hi Guys,

I am glad that you have found a solution to the issue.

Do not hesitate to write back, should you have further questions.

Regards,
George
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
sophia
Top achievements
Rank 1
answered on 15 Sep 2018, 10:42 PM
Such kind of issues with indexing problem to the Printer is really very common as well as problematic as it gives too much trouble to the users. Mostly the new users can't able to access the indexing process from the current page. They get the actual solution from https://supportnumbers.net/blog/hp-printer-assistant-not-opening/ that will be fruitful for them to resolve their issues easily.
0
sophia
Top achievements
Rank 1
answered on 15 Sep 2018, 10:44 PM
Such kind of issues with indexing problem to the Printer is really very common as well as problematic as it gives too much trouble to the users. Mostly the new users can't able to access the indexing process from the current page. They get the actual solution from hp assistant that will be fruitful for them to resolve their issues easily.
0
Hristo
Telerik team
answered on 17 Sep 2018, 10:19 AM
Hi Sophia,

Thank you for updating the thread and sharing your experience. The reported issue in the RadPdfViewer control has been also fixed back in 2014.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
PdfViewer and PdfViewerNavigator
Asked by
willi
Top achievements
Rank 1
Answers by
willi
Top achievements
Rank 1
George
Telerik team
Matthias
Top achievements
Rank 1
sophia
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or