我正在使用iTextG从pdf创建5个doc文件。当我在Android Studio模拟器上进行操作时,它们打开就可以了,但是当我在手机上尝试它时(注释4),doc文件由于某种原因而被破坏。这是代码......
PdfReader reader = new PdfReader(root + "/downloadedfile.pdf");
PrintWriter out = new PrintWriter(new FileOutputStream(root + "/" + day + ".doc"));
Rectangle rect = new Rectangle((float) ((float) 28 + 107*(dayNum-1) + 0.5), 0, (float) ((float) 28 + 107*dayNum + 0.5), reader.getPageSize(1).getHeight());
RenderFilter regionFilter = new RegionTextRenderFilter(rect);
TextExtractionStrategy strategy = new FilteredTextRenderListener(new LocationTextExtractionStrategy(), regionFilter);
out.println(PdfTextExtractor.getTextFromPage(reader, 1, strategy));
reader.close();
out.flush();
out.close();
编辑:root = getcachedir()。toString()...(我已尝试过其他目录)