相关疑难解决方法(0)

如何在Webview中显示pdf文档?

我想在webview上显示pdf内容.这是我的代码:

WebView webview = new WebView(this); 
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true); 
webview.loadUrl("http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf");
Run Code Online (Sandbox Code Playgroud)

我得到一个空白的屏幕.我也设置了互联网许可.

pdf android webview

106
推荐指数
6
解决办法
15万
查看次数

如何在我的Android应用程序中阅读pdf?

我正在申请要求打开pdf.

我在资产文件夹中也有一些pdf,所以我无法直接在webview中打开它.

默认情况下,android不支持pdf.

有没有适用于android的API(MuPdf除外)?

我的设备没有安装任何pdf阅读器,因此ACTION VIEW对我没用

以下不工作.......

在Android上使用Java渲染PDF文件

在应用程序中打开资产文件pdf

你可以建议我任何好的api ...

提前致谢...

android pdf-reader

48
推荐指数
2
解决办法
8万
查看次数

适用于Android的蓝牙和WIFI打印

我们需要一台可以通过蓝牙或wifi连接到Android手机的便携式打印机(手持设备,这很重要).

我目前所知道的:

  • 这次没有适用于Android的标准打印SDK
  • 有一个名为iPrint SDK的非官方SDK.有没有人通过wifi或蓝牙试过?它有用吗?
  • Printershare还声称可以通过程序化方式获得.我可以为每部手机支付5美元的一次性费用.它有很多支持的格式.你有没有尝试过任何手持设备?我向他们询问了支持的蓝牙打印机列表(因为它有一个菜单项"搜索BT打印机"),但他们没有回答.

我已经问过上面需要知道的事情:

  • 你如何从你的Android应用程序打印?
  • 你用的是什么类型的打印机?
  • 是否计划在标准的Android SDK中包含打印?什么是路线图?它现在可用作Beta还是其他什么?
  • 如果我们以某种方式(我不这么认为)通过蓝牙构建自己的打印解决方案,您能推荐标准和协议来检查和学习吗?

printing android bluetooth printers wifi

43
推荐指数
4
解决办法
6万
查看次数

将Pdf页面转换为Android Java中的Bitmap

我需要将PDF文件(PDF页面)转换为Android中的位图(或图像文件).

1.使用Apache的Pdfbox jar.但是它使用了android中不支持的一些java类.2.尝试将图像转换为pdf的Itext jar(我需要它的反向操作)就像我尝试了很多罐子一样.但没有积极的结果.

byte[] bytes;
    try {

        File file = new File(this.getFilesDir().getAbsolutePath()+"/2010Q2_SDK_Overview.pdf");
        FileInputStream is = new FileInputStream(file);

        // Get the size of the file
        long length = file.length();
        bytes = new byte[(int) length];
        int offset = 0;
        int numRead = 0;
        while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
            offset += numRead;
        }


        ByteBuffer buffer = ByteBuffer.NEW(bytes);
        String data = Base64.encodeToString(bytes, Base64.DEFAULT);
        PDFFile pdf_file = new PDFFile(buffer);
        PDFPage page = pdf_file.getPage(2);

        RectF rect = new RectF(0, …
Run Code Online (Sandbox Code Playgroud)

pdf android

38
推荐指数
3
解决办法
5万
查看次数

通过android intent打开在线pdf文件?

目前,我有一个PDF url,我想简单地使用意向来打开它,但是,如果我把它不起作用urlintent

我的代码是这样的,它总是抛出 ActivityNotFoundException 错误

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(law.url), "application/pdf");

try {
    startActivity(intent);
} catch (ActivityNotFoundException e){
    Utility.showErrorDialog(
        ctx,ctx.getResources().getString(R.string.sys_in, 
        ctx.getResources().getString(R.string.err_no_pdf_reader), 
        ctx.getResources().getString(R.string.close));
}
Run Code Online (Sandbox Code Playgroud)

我也尝试了goolge doc方法,但是我的客户拒绝了这个,所以我没有使用这种方法

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setDataAndType(Uri.parse("http://docs.google.com/viewer?url=" 
+ publish.get(Integer.parseInt((String) view.getTag())).pdfURL), "text/html");  
ctx.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

感谢帮助

Log cat错误更新

04-23 18:18:50.487: E/AndroidRuntime(17161): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://oshc.zizsoft.com/oshc_testing.pdf typ=application/pdf }
04-23 18:18:50.487: E/AndroidRuntime(17161):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1568)
04-23 18:18:50.487: E/AndroidRuntime(17161):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1439)
04-23 18:18:50.487: E/AndroidRuntime(17161):    at android.app.Activity.startActivityForResult(Activity.java:3356)
04-23 18:18:50.487: E/AndroidRuntime(17161):    at android.app.Activity.startActivityForResult(Activity.java:3317)
04-23 …
Run Code Online (Sandbox Code Playgroud)

pdf android android-intent

20
推荐指数
6
解决办法
7万
查看次数

在Android应用中打开PDF

我正在开发一个需要在设备中打开pdf文件的应用程序,

我实际上在网上获得了与大多数示例类似的代码.但是,问题是我无法打开文件,控件直接进入"异常"部分.

以下是代码:

public class MyPDFDemo extends Activity 
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)   
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    Button OpenPDF = (Button) findViewById(R.id.button);
    OpenPDF.setOnClickListener(new View.OnClickListener()
    { 
        public void onClick(View v) 
        {
            File pdfFile = new File("/sdcard/Determine_RGB_Codes_With_Powerpoint [PDF Library].pdf"); 
            if(pdfFile.exists()) 
            {
                Uri path = Uri.fromFile(pdfFile); 
                Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
                pdfIntent.setDataAndType(path, "application/pdf");
                pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

                try
                {
                    startActivity(pdfIntent);
                }
                catch(ActivityNotFoundException e)
                {
                    Toast.makeText(MyPDFDemo.this, "No Application available to view pdf", Toast.LENGTH_LONG).show(); 
                }
            }

        }
    });

} …
Run Code Online (Sandbox Code Playgroud)

pdf android

16
推荐指数
1
解决办法
4万
查看次数

实现PDF阅读器的代码示例

我想在我正在做的应用程序中实现PDF阅读器,我找到了几个API,但它们都不是开源的.

你们中的任何人都知道一个好的免费替代品吗?


OP 对Dipak Keshariya的解决方案进行了轻微改编

头等舱

package android.pdf.reader;

import java.io.File;
import java.io.FilenameFilter;

import net.sf.andpdf.pdfviewer.PdfViewerActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class First extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        File images = Environment.getExternalStorageDirectory();
        File[] imagelist = images.listFiles(new FilenameFilter()
        {  
                public boolean accept(File dir, String name)  
                {  
                        return ((name.endsWith(".pdf")));
                }  
        }); 
        String[] pdflist = new String[imagelist.length]; 
        for(int i = 0;i<imagelist.length;i++)
        {
                pdflist[i] = imagelist[i].getName();
        }
        this.setListAdapter(new …
Run Code Online (Sandbox Code Playgroud)

pdf android

10
推荐指数
1
解决办法
8万
查看次数

如何更改Google文档网站在Android中显示PDF的方式?

我使用下面的链接里面WebView展现出pdf file在我的Android应用程序:

这可以工作,并显示PDF,如附图中所示.我遇到的问题是

我想禁用缩放控件,桌面和下载链接.

这是可能的,如果是的话,怎么样?

android google-docs google-docs-api

7
推荐指数
1
解决办法
1817
查看次数

使用mozilla pdf.js在Android WebView中显示PDF文件Android API级别低于19

我在Android WebView中使用mozilla pdf.js来显示PDF文件.

代码在Android API Level 19中运行良好.

Uri path = Uri.parse(Environment.getExternalStorageDirectory().toString() + "/test.pdf");
webView.loadUrl("file:///android_asset/pdfviewer/index.html?file=" + path); 
Run Code Online (Sandbox Code Playgroud)

但它不适用于Android API 16级及以下版本.

设备上显示白色空白屏幕.

有什么方法可以解决这个问题吗?

pdf android webview

7
推荐指数
1
解决办法
1万
查看次数

在 Android 应用程序中创建、编写和显示 PDF 文件

我有一个 android 应用程序,它基本上是一个接受用户输入的表单。此输入存储在数据库中。但我想用用户输入的信息创建一个 pdf 文件并显示它,以便用户可以打印文件或将文件保存到他们的 android 笔记选项卡。最好的方法是什么。我已经看到了 iText,但这不会呈现文件。我在网上找到了这段代码,并对其进行了测试以了解pdf创建的概念。这使用了 Lowagie 2.1.7

    package com.example.sweetiean.androidpdfdemo;

        import android.content.Intent;
        import android.graphics.Bitmap;
        import android.graphics.BitmapFactory;
        import android.graphics.Color;
        import android.net.Uri;
        import android.os.Environment;
        import android.support.v7.app.ActionBarActivity;
        import android.os.Bundle;
        import android.util.Log;
        import android.view.Menu;
        import android.view.MenuItem;
        import android.view.View;
        import android.widget.Button;
        import android.widget.Toast;

        import com.lowagie.text.Document;
        import com.lowagie.text.DocumentException;
        import com.lowagie.text.Font;
        import com.lowagie.text.HeaderFooter;
        import com.lowagie.text.Paragraph;
        import com.lowagie.text.Phrase;
        import com.lowagie.text.pdf.PdfWriter;
        import com.lowagie.text.Image;


        import java.io.ByteArrayOutputStream;
        import java.io.File;
        import java.io.FileOutputStream;
        import java.io.IOException;




    public class MainActivity extends ActionBarActivity {

    private Button createPDF , openPDF;


    @Override
    protected void onCreate(Bundle savedInstanceState) …
Run Code Online (Sandbox Code Playgroud)

pdf android itext

7
推荐指数
1
解决办法
5万
查看次数