yasirsiddiqui / php-google-cloud-print

PHP class to print documents using Google Cloud Print with OAuth2 authorization
91 stars 42 forks source link

Printing pdf from url? #4

Closed solosimpi closed 4 years ago

solosimpi commented 9 years ago

Hello sry for my ver bad english. Your class is awesome, only a question It´s posible to print from a pdf that´s accesible from web, for example: www.mydomain.com/pdf-to-print.pdf ??

yasirsiddiqui commented 9 years ago

I guess you can pass web url to the sendPrintToPrinter() and it should fetch the file but i have not tested that yet. If that doesn't work then you have to download file and save to disk.

rx350h commented 9 years ago

Sorry, for my english, but can You help me, what i should to do if i want to print "URL"? I'm newbie in PHP, I want to print from "URL" without downloading and saving.

rx350h commented 9 years ago

$resarray = $gcp->sendPrintToPrinter($printerid, "Printing Doc using Google Cloud Printing", "www.google.com/landing/cloudprint/testpage.pdf", "url"); it does not work

yasirsiddiqui commented 9 years ago

See this in php documentation about fopen

If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled. If it is switched off, PHP will emit a warning and the fopen call will fail.

Can you try replacing $handle = fopen($filepath, "rb"); with $handle = fopen($filepath, "r"); in GoogleCloudPrint.php

rx350h commented 9 years ago

i think it will be helpful, so in GoogleCloudPrint.php $post_fields = array(
'printerid' => $printerid, 'title' => $printjobtitle, 'ticket' => "{\"version\": \"1.0\",\"print\": {}}", 'content' => $filepath, 'contentType' => "url"
); Where $filepath it's URL like www.example/text.txt, however it was sent to jobs