2

我需要将一个 PDF 文件上传给用户谷歌文档,该文件由 pdfjet 在谷歌应用引擎上生成。我想用 pdfjet 为 gae/j 生成 pdf。pdfjet 使用流来创建 pdf。无论如何将流转换为文件,以便我可以上传给用户谷歌文档。我尝试了 gaevfs 但无法使其工作。如果需要,我可以使用另一个 pdf 生成解决方案或另一个虚拟文件系统等。

PDF 生成代码

ByteArrayOutputStream os = new ByteArrayOutputStream();
PDF pdf = new PDF(os);

谷歌文档 API 代码

DocumentListEntry newEntry = new PdfEntry();
newEntry.setTitle(new PlainTextConstruct("Some Report"));

我无法让它工作的那一行:setFile(File, String)

newEntry.setFile(pdf, "application/pdf");

谢谢。

4

1 回答 1

0

你不能简单地写 from ByteArrayOutputStreamtoFileOutputStream使用该ByteArrayOutputStream.writeTo(OutputStream)方法吗?像这样:

ByteArrayOutputStream os = new ByteArrayOutputStream();
PDF pdf = new PDF(os);  
FileOutputStream fos = new FileOutputStream("myPDF.pdf");
baos.writeTo(os);
于 2010-10-22T12:49:26.617 回答