We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Zoom automatically into a page to remove white space

Is there a way to zoom into a PDF page automatically to remove any white space or margin on screen around content?


3 Replies

DR Deepika Ravi Syncfusion Team April 12, 2023 01:30 AM UTC

Hi Sébastien Arbogast,

We hope you are looking forward to this feature on Windows and web platform. Currently, we do not have support to load the document with "Fit width" in SfPdfViewer on the web and windows platforms. We have considered this requirement and will implement it to load the document with a fit width as a default in the web and windows platforms. This support will be included in the Volume 2 release, which is expected to be rolled out at the end of June 2023.

We have a property for load a PDF document in SfPdfViewer with specified zoom level. The following code example explains the same.

Code snippet:

@override

Widget build(BuildContext context) {

  return Scaffold(

      body: SfPdfViewer.network(

              'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf',

              initialZoomLevel: 1.5));

}


Kindly refer the following link for know more about the initialZoomLevel property,

https://help.syncfusion.com/flutter/pdf-viewer/getting-started#load-document-with-the-specified-scroll-offset-position-or-zoom-level

Regards,

Deepika R



SA Sébastien Arbogast April 14, 2023 12:14 PM UTC

In fact, what I would like to do is a little more advanced than fitting the width of the page to remove any external space. I would also like to zoom in to the page to remove any whitespace between the content of a page and the bounds of the page. Imagine for example if the PDF contains a musical score with some margin around it, I would like to optimize the zoom so that the score is as big as possible on screen without hiding any of it.

To implement something like this, I could get all the content elements of a page with their coordinates, and calculate a bounding box that would contain all these elements, and then zoom into the page until the width of the bounding box coincide with the width of the viewport.

Is there a way to get a list of all the content elements of a PdfPage?



DR Deepika Ravi Syncfusion Team April 17, 2023 08:48 PM UTC

Hi Sébastien Arbogast,


We can retrieve the Pdf page coordinates with the help of syncfusion_flutter_pdf package but it doesn't match with PdfViewer. We changed the Pdf page coordinates according to the viewport size in SfPDViewer, so currently it is not possible to achieve your requirement.


Regards,

Deepika Ravi




Loader.
Up arrow icon