pvginkel / PdfiumViewer

PDF viewer based on Google's PDFium.
Apache License 2.0
967 stars 418 forks source link

Go to last page #15

Closed amadueke closed 9 years ago

amadueke commented 9 years ago

Hi Pieter, looking at using pdfiumviewer for a c# windows project that I'm doing. Integration has been successful so far however i'm stuck at trying to have the viewer default to the the last page of the currently loaded document immediately it loads. I can't find any documentation on it and I'm not even sure this is the right place to come for help. The Adobe reader viewer has a command GoToLastPage that fulfills this goal but for other handicaps that Adobe reader has, my team prefers the PdfiumViewer. Can you please try to help me or point me a direction to get help on this? The c# code that I use to load my pdf document is this.pdfViewer1.Document = PdfiumViewer.PdfDocument.Load(filename); . Thank you.

pvginkel commented 9 years ago

I've created a new version (1.6.1.0) for you that allows you to do this. With the previous version, you were not able to access the PdfRenderer control that actually renders the PDF. Now you are.

How you accomplish this is that you invoke a scroll manually. Specifically, to scroll to the end, use the following code:

pdfViewer1.Renderer.SetDisplayRectLocation(
    new Point(0, -pdfViewer1.Renderer.DisplayRectangle.Bottom)
);

This performs a scroll to the far bottom of the PDF document. This is how it works:

amadueke commented 9 years ago

Thank you very much for this Pieter. I installed your latest version, tested it and it works like a champ. You rock. A great feature would also be to be able to go to a particular page upon display. But I'm not sure how much of a need it would be. Anyway, thank you again for your very quick response and resolution.

pvginkel commented 9 years ago

Could you please create a new issue for this? I'm not able to pick this up right now but it does sound like a nice new feature.

On Fri, Apr 10, 2015, 14:30 amadueke notifications@github.com wrote:

Thank you very much for this Pieter. I installed your latest version, tested it and it works like a champ. You rock. A great feature would also be to be able to go to a particular page upon display. But I'm not sure how much of a need it would be. Anyway, thank you again for your very quick response and resolution.

— Reply to this email directly or view it on GitHub https://github.com/pvginkel/PdfiumViewer/issues/15#issuecomment-91537547 .

Yoda-Man commented 9 years ago

Hi Pieter

Are there plans to make your library support viewing multi page Tiff files?

On 10 April 2015 at 07:41, Pieter van Ginkel notifications@github.com wrote:

I've created a new version (1.6.1.0) for you that allows you to do this. With the previous version, you were not able to access the PdfRenderer control that actually renders the PDF. Now you are.

How you accomplish this is that you invoke a scroll manually. Specifically, to scroll to the end, use the following code:

pdfViewer1.Renderer.SetDisplayRectLocation( new Point(0, -pdfViewer1.Renderer.DisplayRectangle.Bottom) );

This performs a scroll to the far bottom of the PDF document. This is how it works:

  • SetDisplayRectLocation sets the offset from the top the scroll control should render at;
  • You need to put in the negative offset because that is how the scroll control works. You tell it what the top of the control should translate to. So, a top offset of -10 hides the first 10 pixels of the document;
  • You get the full height of the document from Renderer.DisplayRectangle;
  • The input is wrong because if the control would actually do what you'd request, it would hide the complete document above the top coordinates. However, SetDisplayRectLocation does input parameter validation so corrects the input so that the bottom page is still visible.

— Reply to this email directly or view it on GitHub https://github.com/pvginkel/PdfiumViewer/issues/15#issuecomment-91436812 .

pvginkel commented 9 years ago

Sorry, no. This project is limited to viewing PDF files. If you want to request a feature, please create a new issue.