I'm using Android Studio's Webview to convert my web app to mobile app.
my webapp has a login which shows your account's files (pdf files).
but running my default app on Android Studio, won't open these pdf files.
I read here to use Google viewer and just put the link of your PDF file just like below,
WebView webview=new WebView(this);
webview.getSettings().setJavaScriptEnabled(true);
String pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdf);
however, the webapp is setup wherein if you open the PDF file, it doesn't have the .pdf extension. Example is: https://mysite/files/myfiles/1234567_00/. As you see, the link does not point to a direct pdf file (.pdf extension), instead it only had "/1234567_00/". When I try to replace the link above with the URL (without .pdf extension), it won't open.
Is there a way I can get this to work? What should I change here?
Related
I'm developing an app where I need to open ppt, ptx and pdf in google presentations and doc, word and pdf in google doc
I am able to open both apps with an intent with an uri but for that I need the file to be a google workspace file, so that I get the fileId of it
It would be like this:
String link = "https://docs.google.com/presentation/d/” + FILE_ID + “/edit";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(link));
startActivity(i);
Is there a way I can open the files in the app without having the id?
Or even better, is there a way to convert the files to google workspace files in order to get the id?
It would be ppt and ptx to Slides and word and doc to google docs
Thanks!
If anyone is facing the same problem, there really isn't a way to display in the google drive file viewer without the file id from a google drive. So, from what I searched, you can't really use this file viewer unless the file is storaged in a google drive.
add full file location after url=
https://docs.google.com/viewerng/viewer?url=http://example.in/example.ppt
There is a android app named taaghche which you can purchase and read pdf books etc...
I purchased a book and I want to be able to read it on PC not android, and also be able to highlight the text (which is not allowed in the app), But The app stores the pdfs so that the pdf files only opens in the app itself and if you try to open the pdf in another device you'll get the error:
Note that the app actually stores the pdf along with a file with no extension and the same name.
I think the app uses the file with no extension to give permission to the pdf file to be opened.
Here is the two files in a zip to download and have a look.
http://langfox.ir/download/pdfs.zip
Any idea or solution or clue to open this file is greatly appreciated.
The pdf looks encoded/encrypted (I maybe wrong) but I would expect to see a Pdf header, and I don't.
The file without an extension is a JFIF file (JPEG File Interchange Format), if you change the extension to Jpg, or JFIF, you should be able to view it as an image. Or in C# you can just use the Bitmap or Image class to load it
Image.FromFile(theFileName);
I am using web-view in my native android application. But the issue I am facing is that I have a PHP file generatePDF.php which takes sessions, parameters from URL and output pdf file on that URL. The issue is that when I pass that URL to webview directly it doesn't load pdf in webview but instead if I pass direct pdf file link through anchor link it loads.
WebView wv = findViewById(R.id.wvBrowser);
WebSettings ws = wv.getSettings();
wv.loadUrl("http://localhost/generatePDF.php?uid=1");
Above code don't load pdf. But if i add some anchor tag and add above path in href then it opens that pdf.
wv.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=http://localhost/generatePDF.php?uid=1");
I tried like above and it loads pdf directly but it doesn't pass the sessions.
Kindly guide how can I load my generatePDF file directly in web-view
WebView has no ability to display PDFs. Either:
Use something like PDF.js to be able to parse and render PDF in a WebView, or
Use a library to render a PDF as its own view
See this blog post for more on this subject.
I am aware that this question has been asked many times, but I still cannot get it to work. I have a pdf in the raw folder and I am trying to open it in a webview using "https://drive.google.com/viewerng/viewer?embedded=true&url=" to open it in the webview.
I think my problem is I can't get the correct path for the pdf file. I've tried it three different ways, and either the webview says I get an error (the url doesn't exist), or it "opens" the pdf, but the webview displays this text in the middle, "No preview available".
These are the three ways I've tried to get the path of the file.
"android.resource://com.an.example/raw/filename"
"android.resource://" + getPackageName() + "/" + R.raw.filename;
Environment.getExternalStorageDirectory() + "/filename.pdf"
For methods 1 and 3 I have tried "filename" and "filename.pdf"
None of these are allowing the pdf to load in the webview. Below is the code I use to load the pdf. (Note: this method does work if I use a web url and not a local file)
webview = (WebView) findViewById(R.id.webView);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
String pdf = "one_of_the_above_methods";
webview.loadUrl("https://drive.google.com/viewerng/viewer?embedded=true&url=" + pdf);
What am I doing wrong? Is there a better way to load a local pdf inside my app without having it take up the entire activity page?
I have a pdf in the raw folder and I am trying to open it in a webview using "https://drive.google.com/viewerng/viewer?embedded=true&url=" to open it in the webview.
That has never been possible.
Is there a better way to load a local pdf inside my app without having it take up the entire activity page?
The best thing is to not load it inside your app at all. Use the user's preferred PDF viewing app, via ACTION_VIEW.
Beyond that, you could use a slightly modified version of PDF.js on Android 4.4+. Or, use AndroidPdfViewer on a wider range of Android versions, though it makes your APK a lot bigger. See this blog post for more context on these and other (worse) options.
Also, here are sample apps demonstrating:
PDF.js: https://github.com/commonsguy/cw-omnibus/tree/v8.10/PDF/PdfJS
AndroidPdfViewer: https://github.com/commonsguy/cw-omnibus/tree/v8.10/PDF/Pdfium
how to convert android web view in PDF in android programming and save as pdf file
if you ask about convert web page to pdf from android you need make back end .
Ex. you have web page view inside android web view. in this status you need make other file in your server to convert html 2 pdf (you can use HTML2PDF library ) to make that. after that you make button in your project in android to query the html file . in this way you will download the html and convert to pdf in you mobile . i wish help you