I want to read pdf files and display contents on TextView. is it possible ? or just show pdf into WebView or pdfViewer?
i want to do like it,
public class MainActivity extends Activity {
private TextView showText;
String url="http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
showText= (TextView)this.findViewById(R.id.showtext);
showText.setText( ++ convertPdfTotext ++);
}
public void convertPdfTotext(View view)
{
}
}
If you want to use it in text view you can convert it with itext as string,but you'll loose formatting:
PdfTextExtractor parser =new PdfTextExtractor(new PdfReader("C:/Text.pdf"));
parser.getTextFromPage(3);
Use WebView instead and you can enable even zoom.
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);
Related
I have 2 activities in my app, First Activity is simple editText and submit Button, When I press submit, it launches webView Activity and searches the keyword entered in the first activity. Now I want to open the first link Automatically in webview.
public class MainActivity extends AppCompatActivity {
WebView webView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClient());
String query = "firebase";// Get the text from EditText here
String url = "https://www.google.com/search?q="+query;
webView.loadUrl(url);
}
}
My webpage is divided in various parts instead of loading full page, i want to load a part of that page div id = map_canvas.
Below code is giving me full page but i want only one part map_canvas
public class Jetbill extends Activity {
public WebView myWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.jetbill);
myWebView = (WebView) findViewById(R.id.webview);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("http://jetbill.biz/users/login.php");
}
}
I'm trying to load a html file in my webview using this codes. but is show Webpage not available
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.frux.web.R.layout.activity_main);
WebView web = (WebView) findViewById(R.id.web1);
web.loadUrl("file:///android_assets/www/webpage");
}
}
I already edit my codes into this but still webpage not available
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView web = (WebView) findViewById(R.id.web1);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("file://android_assets/www/index.html");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
I just mistype the assets. It should be "asset" without "S".
The file should be extension with html
The easiest way would probably be to put your web resources into the assets folder then call webView.loadUrl("file:///android_asset/www/filename.html");
try this will help you...
web.loadUrl("file:///android_assets/www/webpage");
webpage is a folder or a file? I guess it should be
web.loadUrl("file:///android_assets/www/webpage/file.html");
or
web.loadUrl("file:///android_assets/www/webpage.html");
Write below line
setContentView(R.layout.activity_main);
web.loadUrl("file:///android_assets/www/webpage/index.html");
instead of
setContentView(com.frux.web.R.layout.activity_main);
web.loadUrl("file:///android_assets/www/webpage");
How can we get info from a webpage(link on it that downloads an excel file when you click on it)? What subjects should be searched in order to do that on Android? Thanks.
AFAIK, you will not able to know what are the link is for. There is a way to know about the link of the webview on which user clicks and it is WebViewClient.
Here is a code using which you can know that the clicked link has XLS file or pdf file or others. You can also block the link using that code
public class TestingActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView view = new WebView(getApplicationContext());
view.setWebViewClient(new MwebViewClient());
}
class MwebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.contains(".xls")) {
Log.d("Blah", "This link contains XLS file");
}
return super.shouldOverrideUrlLoading(view, url);
}
}
}
I am using android Webview to load a url to show a pdf file.
Here is my code:
public class TestProgectActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView mtWebView=new WebView(this);
setContentView(mtWebView);
mtWebView.getSettings().setJavaScriptEnabled(true);
mtWebView.loadUrl("https://docs.google.com/viewer?url=http://www.cbwe.gov.in/HTMLEditor1/pdf/sample.pdf");
}
}
It is working for the link "https://docs.google.com/viewer?url=http://www.cbwe.gov.in/HTMLEditor1/pdf/sample.pdf".
But it is not working for "https://docs.google.com/viewer?url=http://www.pancreaze.net/pdf/PANCREAZE.pdf". When I am firing this url through Webview it is showing HTML content in the WebView instead of the actual pdf file. Here is the screenshot.
What is problem in my code?