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?