Android: Binary to PDF - android

I am trying to show a normal PDF document on an Android device.
And I m pretty comfortable in doing so.
The actual problem which I am facing is,
1. PDF docs are saved in binary format in the Backend
2. When I fetch those from my Android App, I get binary content
3. I want to convert this binary format/content into a format which I can show as PDF document within my Android App
Is their any way to achieve this?
Plz help...
Thanks in advance...

You can try this
public class MyPdfViewActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView mWebView=new WebView(MyPdfViewActivity.this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url="+LinkTo);
setContentView(mWebView);
}
}
As answered Shylendra Madda here

Related

Android WebView not loading local HTML files

I'm using the standard Android SDK with Ecliple as provided from the Android website.
What I want to to is to have an activity display a WebView that loads a local HTML-file. Everything works fine until I try to load the webview.
I've placed all the index-files I've tried in the project's assets-folder.
This is the code in my activity:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webView = new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_assets/www/index.html");
setContentView(webView);
}
When I run the app over ADB, I get the following message in the WebView:
Webpage not available
The webpage at file:///android_assets/www/index.html might be temporarily down or it may have moved permanently to a new web address.
I know this problem has been posted before, and I've tried every single solution out there. But it just won't load. It displays online http-addresses just fine, but it doesn't seem to find any of the local files.
Please help me, this drives me mad.
Change this line:
webView.loadUrl("file:///android_assets/www/index.html");
to this :
webView.loadUrl("file:///android_asset/www/index.html");
is android_asset not android_assets :D. Good Luck

file://android_asset/www/index.html was not found

I am new to android programming and I am developing my first apps using eclipse.
I have kept my html and jquery codes inside assets folder.
now this is my code in mainactivity.java
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView)findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
// webView.setWebChromeClient(new WebChromeClient);
webView.loadUrl("file://android_asset/www/index.html");
}
when i installed app on my device and run it,
it says,
webpage not available,
the file at file://android_asset/www/index.html may have been moved permanently
plz help me to solve this
Try changing
webView.loadUrl("file://android_asset/www/index.html");
by
webView.loadUrl("file:///android_asset/www/index.html"); // please see the extra forward slash, they have to be 3.

How to open PDF file in android pdfviewer not in webview

Plan to develope an android application for open web pdf links in my android application.am opening in webview.But its not good to feel its like a pdf.so thats why plan to open in any adobereader application is installed or any other pdfviewer supported applications already installed in android devise open in thar application or open in webbrowser.
my sample code :1
public class MyPdfViewActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView mWebView=new WebView(MyPdfViewActivity.this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url="+LinkTo);
setContentView(mWebView);
}
}
sample code 2:
open in webbrowser
How can i open pdf like in ios webview in android with supported guestures and all.
I think, this will help you to some extent: https://github.com/manjusdm/PDFReader

Android Application doesn't read css file completely

hi I have Android App as I embed HTML file , I added my code and when I test the app I noticed that some of css classes doesn't called as #media also the JQuery doesn't called .
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_elaraby_group);
WebView wv=(WebView) findViewById(R.id.web_engine);
wv.loadUrl("file:///android_asset/index.html");
}
Well you have to provide exact same structure you are using in html page in your asses folder.Otherwise it will not get some files referenced in your html file.And hence those CSS and JavaScript code never gets run.So try with providing same structure as your localhost server.

Android EPUBLIB read/load content

I'm playing with http://www.siegmann.nl/epublib on Android. Can someone please explain the right way to
read epub HTML content,
how to show this on Android (using WebView?),
how to split content into pages and
how to search the content.
Thx 10x.
Answers #2:
Extract epub on file system /mnt/sdcard/epub/
Loading values in webview
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.epub_reader);
webView = (WebView) findViewById(R.id.webview);
Book book = (new EpubReader()).readEpub(new FileInputStream(filename);
String baseUrl="file://mnt/sdcard/epub/OEBPS/"
String data = new String(book.getContents().get(2).getData());
webView.loadDataWithBaseURL(baseUrl, data, "text/html", "UTF-8", null);
}
Regarding your questions:
How to read epub HTML content
I'm not sure what you mean. Do you want all the content? Or something specific?
All the content can be retrieved using Book.getContent().
how to show this on Android (using WebView?),
I would use WebView for this. Haven't tried that myself though.
how to split content into pages
This I don't know what would work best.
how to search the content.
The nl.siegmann.epublib.search package in epublib-tools has code for a simple search functionality.

Categories

Resources