- Posts: 3
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Android development and PDF
Fit to height
- [email protected]
- Topic Author
- Offline
- New Member
-
Less
More
9 years 2 months ago #11771
by [email protected]
Fit to height was created by [email protected]
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)
9 years 2 months ago #11772
by nermeen
Replied by nermeen on topic Fit to height
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.
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.
- [email protected]
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 3
- Thank you received: 0
9 years 2 months ago #11822
by [email protected]
Replied by [email protected] on topic Fit to height
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?
9 years 2 months ago #11831
by emanuele
Replied by emanuele on topic Fit to height
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.
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.
IP: 192.168.0.71
8 years 1 month ago - 8 years 1 month ago #13514
by j.k.
Replied by j.k. on topic Fit to height
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) {
}
}
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: 8 years 1 month ago by j.k..
- cmahoney52
- Offline
- New Member
-
Less
More
- Posts: 7
- Thank you received: 2
IP: 192.168.0.71
8 years 2 weeks ago - 8 years 2 weeks ago #13618
by cmahoney52
Replied by cmahoney52 on topic Fit to height
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.
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.
*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.
Code:
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: 8 years 2 weeks ago by cmahoney52.
Time to create page: 0.412 seconds