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

Zoom to width / Zoom full page

4 Answers 315 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 13 Mar 2012, 02:58 PM
Hi there
Is there anyway to set the zoom to 'Zoom to document width' or 'Zoom to Full Page view' - like the native Adobe Reader?

If not, are there plans to implement these options?

Thanks
Dave

4 Answers, 1 is accepted

Sort by
0
Kammen
Telerik team
answered on 14 Mar 2012, 02:10 PM
Hi David,

This kind of behavior is currently not supported. In some of the future versions we can implement it, but it has not been scheduled yet.

However, in the upcoming service pack a DocumentChanged event will be introduced. With its help, you could achieve the effect of "zoom to document width" by setting the scale factor to a value calculated in the following way:

double minWidth = this.viewer.Document.Pages.Min(p => p.Width);
double k = (this.viewer.ActualWidth - 50 /* Some error like page margins, vertical scrollbar, etc. */) / minWidth;
this.viewer.ScaleFactor = k;

All the best,

Kammen
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Ritwick
Top achievements
Rank 1
answered on 05 Nov 2012, 10:25 AM
Hi Kammen,

The above mentioned code is not compilable. It says RadFixedPage doesnot contain definition for Width in "(p => p.Width)"

Also, setting the scale factor to the pdf viewer directly or through binding doesn't work.

Code snippet for correct usage will help.

I am using Q3 2012 version with .NET 4.0.

Thanks
Ritwick
0
Ritwick
Top achievements
Rank 1
answered on 05 Nov 2012, 11:55 AM
Hi Kammen,

Solved the compilation issue, it should be ActualWidth instead of Width.

But still do not know why the ScaleFactor setting works within DocumentChanged event but not elsewhere. For e.g. if ScaleFactor is set during initialization, it should get applied to the document when it is loaded. Besides, binding to ScaleFactor does not work.

Thanks
Ritwick
0
Kammen
Telerik team
answered on 05 Nov 2012, 04:18 PM
Hello Ritwick,

This is the behavior of the ScaleFactor property by design. We have decided that every time a new document is opened, the scale factor should be reset. That is why you cannot set the scale factor when initializing the document.

On the other hand, if you handle the DocumentChanged event and set the property there, it will be used for the new document.

Greetings,
Kammen
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PDFViewer
Asked by
David
Top achievements
Rank 2
Answers by
Kammen
Telerik team
Ritwick
Top achievements
Rank 1
Share this question
or