在GAE/J上将PDF文件上传到pdfjet生成的Google文档 [英] Uploading a PDF file to Google Docs generated by pdfjet on GAE/J
问题描述
我需要将PDF文件上载到用户google docs,该文件由pdfjet在google app引擎上生成.我想出使用gae/j的pdfjet生成pdf. pdfjet使用流创建pdf.无论如何,有没有将流转换为文件,所以我可以上传给用户谷歌文档.我尝试了gaevfs,但无法正常运行.如果需要,我可以使用其他pdf生成解决方案或其他虚拟文件系统等.
I need to upload a PDF file to users google docs which is generated by pdfjet on google app engine. I figure out to generate pdf using pdfjet for gae/j. pdfjet uses streams to create the pdf. Is there anyway to convert stream to file so I can upload to users google docs. I tried gaevfs but couldn't make it work. I can use another pdf generation solution if needed or another virtual file system etc.
ByteArrayOutputStream os = new ByteArrayOutputStream();
PDF pdf = new PDF(os);
Google Docs API代码
DocumentListEntry newEntry = new PdfEntry();
newEntry.setTitle(new PlainTextConstruct("Some Report"));
我无法执行的行:setFile(File,String)
newEntry.setFile(pdf, "application/pdf");
谢谢.
推荐答案
您难道不能简单地使用ByteArrayOutputStream.writeTo(OutputStream)
方法将ByteArrayOutputStream
写入FileOutputStream
吗?像这样:
Couldn't you simply write from ByteArrayOutputStream
to FileOutputStream
using the ByteArrayOutputStream.writeTo(OutputStream)
method? Like this:
ByteArrayOutputStream os = new ByteArrayOutputStream();
PDF pdf = new PDF(os);
FileOutputStream fos = new FileOutputStream("myPDF.pdf");
baos.writeTo(os);
这篇关于在GAE/J上将PDF文件上传到pdfjet生成的Google文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!