[英]how to solve read only file system error in android programming with eclipse
I am developing a program in which i must create pdf file inside application. 我正在开发一个程序,其中我必须在应用程序内部创建pdf文件。
This is the code that i use for creating pdf file but an error occurred that say 这是我用来创建pdf文件的代码,但是发生了一个错误,说
"/Image.pdf:open failed:EROFS(read-only file system)"
This is my button click code: 这是我的按钮点击代码:
Document document = new Document();
PdfWriter.getInstance(document,new FileOutputStream("Image.pdf"));
document.open();
Image image1 = Image.getInstance("watermark.png");
document.add(image1);
String imageUrl = "http://jenkov.com/images/20081123-20081123-3E1W7902-small-portrait.jpg";
Image image2 = Image.getInstance(new URL(imageUrl));
document.add(image2);
document.close();
尝试在sdcard根目录中写入pdf:
PdfWriter.getInstance(document,new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath()+"Image.pdf"));
first i thank Haresh Chhelana for his answers. 首先,我感谢Haresh Chhelana的回答。
by using this code i can create new pdf file with an image in it. 通过使用此代码,我可以创建带有图像的新pdf文件。
Document document = new Document();
PdfWriter.getInstance(document,new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath()+"/Image.pdf"));
document.open();
Image image1 = Image.getInstance(Environment.getExternalStorageDirectory()+"/01.jpg");
document.add(image1);
document.close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.