Skip to content
This repository has been archived by the owner on Dec 31, 2019. It is now read-only.

Example of actually printing a PDF file? #30

Closed
gduprey opened this issue Feb 22, 2018 · 3 comments
Closed

Example of actually printing a PDF file? #30

gduprey opened this issue Feb 22, 2018 · 3 comments

Comments

@gduprey
Copy link

gduprey commented Feb 22, 2018

So arguably this is likely a documentation issue more than a problem (I hope), but the docs mention that you just pass a File as the content (and presumably application/pdf as the content type), but I canntot get that to work (I get errors about "no implicit conversion of nil into String" from within net/http/generic_request).

I also see other issues where it looks like folks are encoding the PDF content into base64 ahead of time - not sure if that is a choice of a necessity.

So any chance of an example of what you need to minimally print a PDF file via the gem would be much appreciated!

@gduprey
Copy link
Author

gduprey commented Feb 22, 2018

Well, it appears that PDF print works OK (had to think it did or theer would have been a bigger deal in the issues), but you do have to include a ticket hash. So assuming you have a PDF file called test.pdf,

cloud_printer.print(content: File.open('test.pdf', 'r'), content_type: 'application/pdf', ticket: { version: '1.0', print: { } })

Seems to be the minimum. There are plenty of options to the printer job (copies, using the duplexer, scaling/fitting, etc) that are described in the CJT (Cloud Job Ticket) section of the google cloud print API docs.

@dilkhush
Copy link
Contributor

dilkhush commented Mar 1, 2018

@gduprey I have updated the read me with a sample request that takes all the parameters like copies, duplexer, etc.

See this https://github.com/thegengen/cloudprint/pull/31/files for more information

@thegengen Please See this PR

@thegengen
Copy link
Owner

Thank you. PR merged!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants