I converting HTML file to PDF via Google Drive Service. I want to add Header and Footer on pages. How can do that using Java Google Drive API?
PS: If there is not proper way than any workaround would be appreciated.
I don't think you can do this directly using Google Drive API. If you are fine with some workaround, I would use Google Apps Script FooterSection Class:
Upload file using Files.insert() with option convert=true
Either trigger or keep running script on specific folder which does the following:
Modify Footer using FooterSection Class
Export Google Document file as PDF
In order to export PDF, there are two ways I can think of.
Using Document Class of Apps script
doc.getAs("application/pdf")
Or getting export link of PDF from Google Drive API using Files.list() where you can get downloadable link for PDF.
"exportLinks": {
"application/pdf": "https://docs.google.com/feeds/download/spreadsheets/Export?key={FILE_KEY}&exportFormat=pdf",
"application/x-vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/feeds/download/spreadsheets/Export?key={FILE_KEY}&exportFormat=ods",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/feeds/download/spreadsheets/Export?key={FILE_KEY}&exportFormat=xlsx"
},
Related
I haven't been able to find a way to download all pages of a the sheet.
Right now I'm using this link to download the sheet as a txtfile (later I modify it easily to be compatible with JSON): https://docs.google.com/spreadsheets/d/PAGELINK/gviz/tq
This only downloads the first page of the sheet. Is there a particular link where I can download the WHOLE sheet (all pages)?
I'm not using google-sheets-api.
EDIT:I am trying to download it through my android app. Sorry if I was not clear.
At this time there is not a build-in single "link" to download all the sheets in text format but you could create an app that provides that. One alternative among others is to create web app by using Google Apps Script.
I want to download pdf files from http://bookzz.org/ using java. How I can pass a file name to the site and get list to choose from? How can I make all these steps run in the background?
You can use e.g. HtmlUnit to access a web site via java.
You can use this to perform searches in the form and than use the links to download the files.
I'm trying to store a file into Google NearLine using a java program and Google's Cloud Storage API. But I'm having difficulty finding out how to do this.
I think I have to convert the File object into a StorageObject, but not sure how to do it.
Here's a link to the doc's for the StorageObject.
https://developers.google.com/resources/api-libraries/documentation/storage/v1beta2/java/latest/com/google/api/services/storage/model/StorageObject.html#set(java.lang.String,%20java.lang.Object)
Thanks.
Note: I've been using this link as a guide:
https://cloud.google.com/storage/docs/json_api/v1/json-api-java-samples
However, this only shows you how to access the bucket, not upload files to the bucket.
To upload files, use Storage.Objects.Insert: https://developers.google.com/resources/api-libraries/documentation/storage/v1beta2/java/latest/com/google/api/services/storage/Storage.Objects.Insert.html
In the project I'm currently working on need to display pdf or excel files to users in their web browser.
We are using java to build up server side and jquery as main js lib for front-end.
What should I do to make this possible?
Or say, what jar or js do I need to rely on (perferably a js lib, but, well.. I have no clue right now..)?
Thanks in advance. :)
It's simple buddy, follow these steps:
Open http://www.scribd.com/
Sign up
Sign in
Upload your excel or pdf file
Get it's iframe code
Place the iframe code in your webpage.
Done
Here are some few clews :
For pdf you can use the built-in of your browser if any, or you could use pdf.js.
For Microsoft documents, you should use Apache POI on server side, and maybe convert it in an other format like csv or json to send it back to your js client
You can make use Jquery datatables tool, to enable export to PDF/ excel. I have used this in earlier project, works very well. It's best part is it is configurable.
http://www.datatables.net/
I would like to display some files from google drives embedded on a website.
I'm downloading the pdf's so they use the adobe plugin.
<object data="https://docs.google.com/..." width="100%" height="100%"></object>
But I would like to display other files (word/excel,...) on the website too.
At the moment I'm using preview but I can't find a way to zoom in/out,download button,...
<iframe src="https://docs.google.com/file/d/googleId/preview" width="100%" height="100%"></iframe>
I could also use /edit in stead of /preview but this gives the entire drive ui in an Iframe.
Is there another way to display a drive file on a website?
My application has all the drive Id's stored of the files it has to display. All the users who use the application have read access to the file!
You can easily embed any document using Google Docs Viewer, like this:
<iframe src="http://docs.google.com/viewer?url=https%3A%2F%2Fdocs.google.com%2Fuc%3Fexport%3Ddownload%26id%3D0BzEbtMoF6IXbRGE1MUtHYTI1Rkk&embedded=true" width="450" height="350"></iframe>
where 0BzEbtMoF6IXbRGE1MUtHYTI1Rkk is the file ID.
The other way to display these files would be to export them as PDF. For this, you can use the exportLinks of a file resource.
Google provide an example of how to fetch these export link in the document about downloading files with the Drive SDK.