我需要将PDF文件上传到用户google文档,这是由谷歌应用引擎上的pdfjet生成的。我想用pdfjet为gae / j生成pdf。 pdfjet使用流来创建pdf。反正有没有将流转换为文件,所以我可以上传到用户谷歌文档。我试过gaevfs,但无法使它工作。如果需要,我可以使用另一种pdf生成解决方案或其他虚拟文件系统等。
ByteArrayOutputStream os = new ByteArrayOutputStream();
PDF pdf = new PDF(os);
DocumentListEntry newEntry = new PdfEntry();
newEntry.setTitle(new PlainTextConstruct("Some Report"));
newEntry.setFile(pdf, "application/pdf");
感谢。
答案 0 :(得分:0)
你不能简单地使用ByteArrayOutputStream
方法从FileOutputStream
写到ByteArrayOutputStream.writeTo(OutputStream)
吗?像这样:
ByteArrayOutputStream os = new ByteArrayOutputStream();
PDF pdf = new PDF(os);
FileOutputStream fos = new FileOutputStream("myPDF.pdf");
baos.writeTo(os);