Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC:

Fit to height 7 years 2 months ago #11771

  • matthew.perkins@lesmills.com
  • matthew.perkins@lesmills.com's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 3
  • Thank you received: 0
I have a PDF file where each page is a different height. The library seems to create a viewport as large as the largest page which then the smaller pages have a large amount of empty space above and below the page which is centred in the page.. Any advice? (This issue exists on both Android and iOS)
The topic has been locked.

Fit to height 7 years 2 months ago #11772

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
This is not an issue, it's the default behavior.

You can change this behavior by modifying the vLayout method of the appropriate layout mode.

You will need to calculate the scale for every page based on its height, and save it into an array for example.
The following user(s) said Thank You: matthew.perkins@lesmills.com
The topic has been locked.

Fit to height 7 years 2 months ago #11822

  • matthew.perkins@lesmills.com
  • matthew.perkins@lesmills.com's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 3
  • Thank you received: 0
Thank you for your help nermeen. I have managed to make this work on android by using a combination of align_page_top setting and and array of values instead of using the m_th variable. However, I have been having issues with the iOS implementation. it seems to not have the align_page_top flag and I assume that I will just create an array to replace the variable m_doch. Any advice to make the pdfs align top?
The topic has been locked.

Fit to height 7 years 2 months ago #11831

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
Hi,

iOS version doesn't have align_page_top parameter, but you can edit the vLayout method of the appropriate layout mode and set to 0 (or to m_page_gap /2) the y parameter of SetRect method when used.
The topic has been locked.

Fit to height 6 years 1 month ago #13514

  • j.k.
  • j.k.'s Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 3
  • Thank you received: 0
Hi,
we are using the Android library, it has been added 2-3 years ago and we haven't touched it since. Standard license.
You are saying we should modifying the vLayout method of the appropriate layout mode.
However, I can find this method with an empty body in PdfView class, and no class extends or implements it in the library or my project.

I also read elsewhere that we could change Global. def_view in order to get different default view modes - I want to fit to width.
I tried all values and nothing changed.

Can you help me out

PS: I fixed my problem like so:

public void fitPagesToScreenWidth(float screenWidth) {
try {
float ratioOfScreenToSinglePage = screenWidth / pdfView.vGetPage(1).GetWidth();
float scaleToFitTwoPagesToScreenWidth = ratioOfScreenToSinglePage * pdfView.vGetMinScale() / 2;
pdfView.vSetScale(scaleToFitTwoPagesToScreenWidth, 0, 0);
} catch (Exception ignored) {

}
}
Last edit: by j.k..
The topic has been locked.

Fit to height 6 years 4 weeks ago #13618

  • cmahoney52
  • cmahoney52's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 7
  • Thank you received: 2
I noticed you're using PdfView. The latest library uses PDFLayoutVew, as PdfView is now deprecated. PDFLayoutView does not have a way currently that I've found to set the page scale to fix the issue of certain pages not filling the screen due to scaling. When using PDFLayoutView.PDFSetView(3), that should fix up Global.def_view to match Single page view mode, which is great, but certain pages still aren't scaling into view properly if the PDF has pages that aren't the same size.

*EDIT*

To solve this problem, I used the PDFViewPager instead of the PDFLayoutView, which has the ability to open a PDF using the following code snippet.
pdfView.PDFOpen(document, 0);

This opens the PDF as normal, but fits it to fill the screen regardless of page size. You can extend the PDFViewPager to add in functionality that you need, such as registering an OnPageChangeListener as normal for a ViewPager to track page turns, etc. I strongly suggest using the PDFViewPager rather than PDFLayoutView if you need to display a PDF page by page with each page fit to screen individually.
Last edit: by cmahoney52.
The topic has been locked.
  • Page:
  • 1
Powered by Kunena Forum