Download PDF to Google Docs created by pdfjet on GAE / J

I need to upload a pdf file to google google files generated by pdfjet in google engine. I get the opportunity to generate pdf using pdfjet for gae / j. pdfjet uses streams to create pdf. Is there anyway to convert the stream to a file so that I can upload to Google Docs. I tried gaevfs but couldn't get it to work. I can use another solution to generate PDF, if necessary, or another virtual file system, etc.

PDF Generation Code

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

Google Docs API Code

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

The line that I could not get to make it work: setFile (File, String)

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

Thank.

+2
1

ByteArrayOutputStream FileOutputStream ByteArrayOutputStream.writeTo(OutputStream)? :

ByteArrayOutputStream os = new ByteArrayOutputStream();
PDF pdf = new PDF(os);  
FileOutputStream fos = new FileOutputStream("myPDF.pdf");
baos.writeTo(os);
0

Source: https://habr.com/ru/post/1771284/


All Articles