Android PDF File not fit into the screen - android

I trying to display the PDF file into my android application but content not fit into the height and width of the screen.
I am trying to pdf convert into HTML and then display but all content align into left direction.

To make a PDF file fit into the screen in Android, you can do the following:
Use a library such as PdfViewer or MuPDF to display the PDF file.
These libraries usually have options to scale and fit the PDF
contents to the screen.
Use a ScrollView to wrap the PDFViewer or MuPDF component. This
allows the user to pan and zoom the PDF file if needed.
Set the width and height of the PDFViewer or MuPDF component to
match_parent, to take up the entire screen.
Example using PdfViewer:
<com.github.barteksc.pdfviewer.PDFView
android:id="#+id/pdfView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
PDFView pdfView = findViewById(R.id.pdfView);
pdfView.fromUri(pdfUri)
.enableSwipe(true)
.swipeHorizontal(false)
.enableDoubletap(true)
.defaultPage(0)
.enableAnnotationRendering(false)
.password(null)
.scrollHandle(null)
.load();

Related

Use drawable inside HTML Page

I am developing an application in which I am loading an HTML page inside Webview. I am to use an image in that HTML which is inside my drawable. How would I give path to that image inside HTML.

Can't use custom images as icons using the "icon" property for android and IOS nativescript

I'm trying to use the "icon" property in the Navigation button tag to use a custom image as an icon.
It works on Android, but in iOS the image is oversized. I can't resize it using scss or setting the height in the tags itself.
I can't even set the visibility property to false using platform specific css on iOS to view the default
How can I:
Make the image hidden on iOS, and make the default
Resize the Image. image of HTML code
Code base where we can see what you have tried is always good practice in StackOverflow.
However, if we assume that you are using res:// like this
<NavigationButton icon="res://ic_menu" />
the solution is to provide different scaled images in your resources folder located in app/App_Resources/iOS (or Android). See how to handle different images for different screen sizes from your App_Resources here for iOS and here for Android.
However if you want to use one image and control it with CSS and the image properties (width, height, ect) you might create your own folder, for example images and use it with relative
<Image src="~/images/logo.png" stretch ="none" / >

Displaying a image captured using Camera inside an html image tag placed within a WebView - Xamarin.Android

I'm looking for a way on to display the image captured using Camera2 API in Xamarin.Android inside an HTML tag which is placed within a WebView.
Though it was possible to obtain the File URi where the image is located, setting it into the image tag which I have tried, isn't working. I also want to know whether this kind of thing can be done in Native Android.
You can encode the content of the image in base64, and than set it in the src of your img tag like this:
<img src="data:image/jpg;base64,VeryLongBase64EncodedImageData"/>

Can i center external content in a WebView?

I am loading an image from external url directly in a WebView. So now i want to center that image. I can't edit the file to add css or js. Is it possible and when it is, how?

Android Webview: Images that are too large for the screen

I'm looking for a way to have images appear in a WebView that initially fits the screen, instead of showing the actual size. Is there a way to do this?
How is it different if:
1) I open an html file with an img tag to the image
2) I open the image file directly
Thanks for any assistance.
I ended up using:
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setUseWideViewPort(true);
To make the contents of the page fit to the WebView.
If I understand the question, you have an image on a web page that has dimensions X x Y and when you load the webpage into a WebView you want it to take up the dimensions of the android device (X1 x Y1). To do this pass a querystring to the url which renders the height and the width of the image at 100%. Also have the layout_width and layout_height of the webview set to the appropriate values.
If you load the image directly into the WebView, you can set the height and width of the image
You can use Webview's LayoutAlgorithm. But this will resize only those images with Width greater than the width of the device. This won't help you with images smaller than the screen.
Link: Can Android's WebView automatically resize huge images?
Another Solution is using a Javascript or an External Library like HTML Cleaner to remove the
<img> size attributes and then change their size via code and getWidth().

Categories

Resources