Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法读取由iText\uuu OKBPDF生成的pdf 导入android.os.Bundle; 导入android.app.Activity; 导入android.view.Menu; 导入java.io.FileOutputStream; 导入android.app.Activity; 导入android.os.Bundle; 导入android.os.Environment; 导入com.itextpdf.text.Document; 导入com.itextpdf.text.paragration; 导入com.itextpdf.text.pdf.PdfWriter; 公共类MainActivity扩展了活动{ 私有静态字符串文件=“/HelloWorld.pdf”; @凌驾 创建时受保护的void(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); 试一试{ 文档=新文档(); 布尔值mExternalStorageAvailable=true; 布尔值mExternalStorageWriteable=false; String state=Environment.getExternalStorageState(); if(环境、介质、安装等于(状态)){ //我们可以读写媒体 mExternalStorageAvailable=mExternalStorageWriteable=true; }else if(Environment.MEDIA\u MOUNTED\u READ\u ONLY.equals(state)){ //我们只能阅读媒体 mExternalStorageAvailable=true; mExternalStorageWriteable=false; }否则{ //还有一些问题。它可能是许多其他州中的一个,但我们所需要的就是它 //要知道,我们既不会读也不会写 mExternalStorageAvailable=mExternalStorageWriteable=false; } 字符串文件=null; if(mExternalStorageWriteable){ file=Environment.getExternalStorageDirectory().getPath()+文件; } getInstance(文档,新文件输出流(文件)); document.open(); 段落p=新段落(“你好,iText World!”); 文件.添加(p); document.close(); }捕获(例外e){ e、 printStackTrace(); } } }_Java_Android_Itext - Fatal编程技术网

无法读取由iText\uuu OKBPDF生成的pdf 导入android.os.Bundle; 导入android.app.Activity; 导入android.view.Menu; 导入java.io.FileOutputStream; 导入android.app.Activity; 导入android.os.Bundle; 导入android.os.Environment; 导入com.itextpdf.text.Document; 导入com.itextpdf.text.paragration; 导入com.itextpdf.text.pdf.PdfWriter; 公共类MainActivity扩展了活动{ 私有静态字符串文件=“/HelloWorld.pdf”; @凌驾 创建时受保护的void(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); 试一试{ 文档=新文档(); 布尔值mExternalStorageAvailable=true; 布尔值mExternalStorageWriteable=false; String state=Environment.getExternalStorageState(); if(环境、介质、安装等于(状态)){ //我们可以读写媒体 mExternalStorageAvailable=mExternalStorageWriteable=true; }else if(Environment.MEDIA\u MOUNTED\u READ\u ONLY.equals(state)){ //我们只能阅读媒体 mExternalStorageAvailable=true; mExternalStorageWriteable=false; }否则{ //还有一些问题。它可能是许多其他州中的一个,但我们所需要的就是它 //要知道,我们既不会读也不会写 mExternalStorageAvailable=mExternalStorageWriteable=false; } 字符串文件=null; if(mExternalStorageWriteable){ file=Environment.getExternalStorageDirectory().getPath()+文件; } getInstance(文档,新文件输出流(文件)); document.open(); 段落p=新段落(“你好,iText World!”); 文件.添加(p); document.close(); }捕获(例外e){ e、 printStackTrace(); } } }

无法读取由iText\uuu OKBPDF生成的pdf 导入android.os.Bundle; 导入android.app.Activity; 导入android.view.Menu; 导入java.io.FileOutputStream; 导入android.app.Activity; 导入android.os.Bundle; 导入android.os.Environment; 导入com.itextpdf.text.Document; 导入com.itextpdf.text.paragration; 导入com.itextpdf.text.pdf.PdfWriter; 公共类MainActivity扩展了活动{ 私有静态字符串文件=“/HelloWorld.pdf”; @凌驾 创建时受保护的void(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); 试一试{ 文档=新文档(); 布尔值mExternalStorageAvailable=true; 布尔值mExternalStorageWriteable=false; String state=Environment.getExternalStorageState(); if(环境、介质、安装等于(状态)){ //我们可以读写媒体 mExternalStorageAvailable=mExternalStorageWriteable=true; }else if(Environment.MEDIA\u MOUNTED\u READ\u ONLY.equals(state)){ //我们只能阅读媒体 mExternalStorageAvailable=true; mExternalStorageWriteable=false; }否则{ //还有一些问题。它可能是许多其他州中的一个,但我们所需要的就是它 //要知道,我们既不会读也不会写 mExternalStorageAvailable=mExternalStorageWriteable=false; } 字符串文件=null; if(mExternalStorageWriteable){ file=Environment.getExternalStorageDirectory().getPath()+文件; } getInstance(文档,新文件输出流(文件)); document.open(); 段落p=新段落(“你好,iText World!”); 文件.添加(p); document.close(); }捕获(例外e){ e、 printStackTrace(); } } },java,android,itext,Java,Android,Itext,我正在尝试为另一组数据再生成一个文件,生成的文件大小为0kb,打开时会显示消息“Adobe Reader无法打开”List.pdf“并键入或因为文件已损坏”。iText需要许可证密钥。检查logcat是否存在异常。进入他们的网站获取许可证密钥并查看如何实施。您确定没有遗漏任何登录到logcat的异常吗?乍一看,这段代码似乎是正确的。 import android.os.Bundle; import android.app.Activity; import android.view.Menu; i

我正在尝试为另一组数据再生成一个文件,生成的文件大小为0kb,打开时会显示消息“Adobe Reader无法打开”List.pdf“并键入或因为文件已损坏”。

iText需要许可证密钥。检查logcat是否存在异常。进入他们的网站获取许可证密钥并查看如何实施。

您确定没有遗漏任何登录到logcat的异常吗?乍一看,这段代码似乎是正确的。
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import java.io.FileOutputStream;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;

import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;

    import com.itextpdf.text.pdf.PdfWriter;

public class MainActivity extends Activity {
    private static String FILE = "/HelloWorld.pdf";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
</i>

        try {
            Document document = new Document();
            boolean mExternalStorageAvailable = true;
            boolean mExternalStorageWriteable = false;
            String state = Environment.getExternalStorageState();

            if (Environment.MEDIA_MOUNTED.equals(state)) {
            // We can read and write the media
            mExternalStorageAvailable = mExternalStorageWriteable = true;
            } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
            // We can only read the media
            mExternalStorageAvailable = true;
            mExternalStorageWriteable = false;
            } else {
            // Something else is wrong. It may be one of many other states, but all we need
            //  to know is we can neither read nor write
            mExternalStorageAvailable = mExternalStorageWriteable = false;
            }
            String file = null;
            if(mExternalStorageWriteable) {
            file = Environment.getExternalStorageDirectory().getPath() + FILE;
            }

            PdfWriter.getInstance(document,new FileOutputStream(file));
            document.open();
            Paragraph p = new Paragraph("Hello iText World!");
            document.add(p);
            document.close();

            } catch (Exception e) {
            e.printStackTrace();
            }
    }


}