Impressão via Google Cloud no Ubuntu


Primeiramente gostaria de salientar que não sou o autor principal do conteúdo deste artigo. A minha intenção é de mostrar o que outros autores tem realizado (referenciando links para o conteúdo original) neste blog até como um guia pessoal para uso próprio e ainda compartilhar minhas anotações e pequenas modificações que realizo no conteúdo, desejando que possa ajudar mais alguém em algum lugar.
First and foremost, I take no credit for any of this post’s content. I am really just taking what others have done (which I have links to bellow) and am putting it on my blog for a personal reference and hopefully the small changes that I made to their guides will help someone somewhere.

Link: https://www.niftiestsoftware.com/cups-cloud-print/

Para listar todas as suas impressoras disponiveis no google cloud print no servidor CUPS, instale o pacote cupscloudprint abaixo:

Instale o pacote do link abaixo:
wget https://niftyrepo.niftiestsoftware.com/cups-cloud-print/packages/cupscloudprint_20140814.2-1_all.deb 
dpkg -i cupscloudprint_20140814.2-1_all.deb 
/usr/share/cloudprint-cups/setupcloudprint.py

Edite o arquivo de configuração:
sudo gedit /etc/cloudprint.conf

[Google]
Username = something@gmail.com
Password = PASSGOESHERE

Reinicie o Cups
sudo service cups restart


Acesse http://127.0.0.1:631
firefox http://127.0.0.1:631

Adicione uma impressora de rede "Google Cloud Print", crie como "Google" de modelo "Cloud Print"

Por exemplo para imprimir no Google Docs: cloudprint://Save%20to%20Google%20Docs
O nome de suas impressoras voce consulta em = http://www.google.com/cloudprint
Mas o ideal é consultar estes nomes com o script fornecido pelo autor (http://www.niftiestsoftware.com/cups-cloud-print/) da seguinte forma:
wget https://raw.github.com/simoncadman/CUPS-Cloud-Print/c5d53cb5400773ba3c4716b8bd129fd018f017ca/listcloudprinters.py
python listcloudprinters.py
\\\PDF - cloudprint://%5C%5C%5CPDF
\\\Photosmart_C7200 - cloudprint://%5C%5C%5CPhotosmart_C7200
\\\Photosmart_C7200_fax - cloudprint://%5C%5C%5CPhotosmart_C7200_fax
Print to Google Docs - cloudprint://Print%20to%20Google%20Docs

Assim o nome correto é : cloudprint://Print%20to%20Google%20Docs

Para transformar (encode) em html = http://meyerweb.com/eric/tools/dencoder/


TEXTO original do autor (http://www.niftiestsoftware.com/cups-cloud-print/) :
Add a new printer ( via http://127.0.0.1:631 or usual interface ) as a 'Google Cloud Print' network printer. Select the 'Make' as Google, and 'Model' as Cloud Print.
Supply the connection name as a simple URI pointing to the printer you want to setup, for example:
cloudprint://Print%20to%20Google%20Docs for the Google Docs printer - remembering to URL encode your spaces ( you can find your printers on http://www.google.com/cloudprint ).



Erro quando o nome da impressora não esta correto:

var/log/cups/cloudprint_log

Printing file /tmp/3347-anonymous-cupsjob-10985
Running /usr/lib/cloudprint-cups/submitjob.py
Converted to PDF as /tmp/3347-anonymous-cupsjob-10985.pdf
Sending /tmp/3347-anonymous-cupsjob-10985.pdf to cloud
ERROR: Printer 'Save%20to%20Google%20Docs' not found
/tmp/3347-anonymous-cupsjob-10985.pdf sent to cloud print, deleting
Deleted /tmp/3347-anonymous-cupsjob-10985
Deleted /tmp/3347-anonymous-cupsjob-10985.pdf

/var/log/cups/error_log

E [10/Nov/2011:12:51:02 -0200] [Job 3347] Printer 'Save%20to%20Google%20Docs' not found
D [10/Nov/2011:12:51:02 -0200] [Job 3347] The following messages were recorded from 12:50:59 to 12:51:02
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Adding start banner page "none".
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Adding end banner page "none".
D [10/Nov/2011:12:51:02 -0200] [Job 3347] File of type application/vnd.cups-banner queued by "anonymous".
D [10/Nov/2011:12:51:02 -0200] [Job 3347] hold_until=0
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Queued on "Save_to_Google_Docs" by "anonymous".
D [10/Nov/2011:12:51:02 -0200] [Job 3347] job-sheets=none,none
D [10/Nov/2011:12:51:02 -0200] [Job 3347] argv[0]="Save_to_Google_Docs"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] argv[1]="3347"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] argv[2]="anonymous"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] argv[3]="Test Page"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] argv[4]="1"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] argv[5]="job-uuid=urn:uuid:db5a7f31-6a49-3560-543e-14f28a1d5285 job-originating-host-name=localhost"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] argv[6]="/var/spool/cups/d03347-001"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[0]="CUPS_CACHEDIR=/var/cache/cups"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[1]="CUPS_DATADIR=/usr/share/cups"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[2]="CUPS_DOCROOT=/usr/share/cups/doc-root"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[3]="CUPS_FONTPATH=/usr/share/cups/fonts"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[4]="CUPS_REQUESTROOT=/var/spool/cups"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[5]="CUPS_SERVERBIN=/usr/lib/cups"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[6]="CUPS_SERVERROOT=/etc/cups"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[7]="CUPS_STATEDIR=/var/run/cups"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[8]="HOME=/var/spool/cups/tmp"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[9]="PATH=/usr/lib/cups/filter:/usr/bin:/usr/sbin:/bin:/usr/bin"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[10]="SERVER_ADMIN=root@master"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[11]="SOFTWARE=CUPS/1.4.3"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[12]="TMPDIR=/var/spool/cups/tmp"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[13]="TZ=America/Sao_Paulo"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[14]="USER=root"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[15]="CUPS_SERVER=/var/run/cups/cups.sock"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[16]="CUPS_ENCRYPTION=IfRequested"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[17]="IPP_PORT=631"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[18]="CHARSET=utf-8"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[19]="LANG=pt_BR.UTF-8"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[20]="PPD=/etc/cups/ppd/Save_to_Google_Docs.ppd"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[21]="RIP_MAX_CACHE=1951380k"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[22]="CONTENT_TYPE=application/vnd.cups-banner"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[23]="DEVICE_URI=cloudprint://Save%20to%20Google%20Docs"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[24]="PRINTER_INFO=Save to Google Docs"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[25]="PRINTER_LOCATION=Google Cloud Printer"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[26]="PRINTER=Save_to_Google_Docs"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[27]="CUPS_FILETYPE=document"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] envp[28]="FINAL_CONTENT_TYPE=application/vnd.cups-postscript"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Started filter /usr/lib/cups/filter/bannertops (PID 10981)
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Started filter /usr/lib/cups/filter/pstopdf (PID 10982)
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Started filter /usr/lib/cups/filter/pdftopdf (PID 10983)
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Started filter /usr/lib/cups/filter/cpdftocps (PID 10984)
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Started backend /usr/lib/cups/backend/cloudprint (PID 10985)
D [10/Nov/2011:12:51:02 -0200] [Job 3347] load_banner(filename="/var/spool/cups/d03347-001")
D [10/Nov/2011:12:51:02 -0200] [Job 3347] pstopdf 5 args: 3347 anonymous Test Page 1 job-uuid=urn:uuid:db5a7f31-6a49-3560-543e-14f28a1d5285 job-originating-host-name=localhost
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PPD: /etc/cups/ppd/Save_to_Google_Docs.ppd
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Page = 595x842; 0,0 to 595,842
D [10/Nov/2011:12:51:02 -0200] [Job 3347] pdftops argv[5] = 3347 anonymous Test Page 1 job-uuid=urn:uuid:db5a7f31-6a49-3560-543e-14f28a1d5285 job-originating-host-name=localhost
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PPD: /etc/cups/ppd/Save_to_Google_Docs.ppd
D [10/Nov/2011:12:51:02 -0200] [Job 3347] /usr/bin/pdftops supports '-origpagesizes': yes
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PNG image: 128x128x8, color_type=6 (RGB+ALPHA)
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PNG image: 192x128x8, color_type=2 (RGB)
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PostScript Level: 2
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Duplex: no
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Resolution: 
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Resolution: 
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Page size: A4
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Page size: A4
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Width: 595, height: 842, absolute margins: 0, 0, 595, 842
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Width: 595, height: 842, absolute margins: 0, 0, 595, 842
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Relative margins: 0, 0, 0, 0
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PPD options: -dDEVICEWIDTHPOINTS=595 -dDEVICEHEIGHTPOINTS=842
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PostScript to be injected: 
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Running cat | /usr/bin/gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dAutoRotatePages=/None -dAutoFilterColorImages=false                -dNOPLATFONTS -dPARANOIDSAFER -sstdout=%stderr -dColorImageFilter=/FlateEncode                 -dPDFSETTINGS=/printer                 -dColorConversionStrategy=/LeaveColorUnchanged -dDoNumCopies -dDEVICEWIDTHPOINTS=595 -dDEVICEHEIGHTPOINTS=842 -sOutputFile=-  -c .setpdfwrite -f -
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Relative margins: 0, 0, 0, 0
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PPD options: -level2 -origpagesizes
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PostScript to be injected: 
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Device copies: 1; device collate: 
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Running /usr/bin/pdftops  -level2 -origpagesizes /tmp/pdftops.oL2x1n -
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Running pstops '3347' 'anonymous' 'Test Page' '1' ' job-uuid=urn:uuid:db5a7f31-6a49-3560-543e-14f28a1d5285 job-originating-host-name=localhost'
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Page = 595x842; 0,0 to 595,842
D [10/Nov/2011:12:51:02 -0200] [Job 3347] slow_collate=0, slow_duplex=0, slow_order=0
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Before copy_comments - %!PS-Adobe-3.0
D [10/Nov/2011:12:51:02 -0200] [Job 3347] %!PS-Adobe-3.0
D [10/Nov/2011:12:51:02 -0200] [Job 3347] %%LanguageLevel: 2
D [10/Nov/2011:12:51:02 -0200] [Job 3347] %%DocumentSuppliedResources: (atend)
D [10/Nov/2011:12:51:02 -0200] [Job 3347] %%DocumentMedia: plain 595 842 0 () ()
D [10/Nov/2011:12:51:02 -0200] [Job 3347] %%BoundingBox: 0 0 595 842
D [10/Nov/2011:12:51:02 -0200] [Job 3347] %%Pages: 1
D [10/Nov/2011:12:51:02 -0200] [Job 3347] %%EndComments
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Before copy_prolog - %%BeginDefaults
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Before copy_setup - %%BeginSetup
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Before page loop - %%Page: 1 1
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Copying page 1...
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PAGE: 1 1
D [10/Nov/2011:12:51:02 -0200] [Job 3347] pagew = 595.0, pagel = 842.0
D [10/Nov/2011:12:51:02 -0200] [Job 3347] bboxx = 0, bboxy = 0, bboxw = 595, bboxl = 842
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PageLeft = 0.0, PageRight = 595.0
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PageTop = 842.0, PageBottom = 0.0
D [10/Nov/2011:12:51:02 -0200] [Job 3347] PageWidth = 595.0, PageLength = 842.0
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Wrote 1 pages...
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Converting print job to PDF
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Sending document to Cloud Print
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Set job-printer-state-message to "Printer 'Save%20to%20Google%20Docs' not found", current level=ERROR
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Cleaning up temporary files
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Printing Successful
D [10/Nov/2011:12:51:02 -0200] [Job 3347] Backend returned status 1 (failed)
D [10/Nov/2011:12:51:02 -0200] [Job 3347] End of messages
D [10/Nov/2011:12:51:02 -0200] [Job 3347] printer-state=3(idle)
D [10/Nov/2011:12:51:02 -0200] [Job 3347] printer-state-message="Printing Successful"
D [10/Nov/2011:12:51:02 -0200] [Job 3347] printer-state-reasons=none



Para adicionar as suas impressoras já configuradas no CUPS no google cloud print, instale o pacote cloudprint abaixo:

sudo apt-get update 
sudo apt-get install build-essential python-dev libcups2-dev
sudo apt-get install python-setuptools python-cups python-daemon python-pkg-resources
sudo easy_install pip
sudo pip install cloudprint pycups
cloudprint

Configurar como serviço do linux:

sudo cp .cloudprintauth .cloudprintauth.sasl /root
sudo nano /etc/init.d/cloudprint


 
#!/bin/sh
            # /etc/init.d/cloudprint
            # Description: Starts the Google Cloud Print script on startup
            # ----------------
            #
            # adapted for Optware for Broadcomm DD-WRT
            # see https://github.com/armooo/cloudprint/issues/46  for code basis
            # acks to casestudies  and   tomslominski

            # need to check for authfile, and if not there, copy it from /opt/etc/cloudprint/

            PIDFILE="/var/run/cloudprint.pid"
            DIR="/home/tom/scripts/cloudprint"
            AUTHFILEROOT="/tmp/.cloudprintauth"
            AUTHFILEOPT="/home/tom/scripts/cloudprint/.cloudprintauth"
            PYBIN="python"


            case $1 in
                start)
                        ###  check for account file and create
                    if [ ! -f $AUTHFILEROOT ]; then
                        test -d /opt/etc/cloudprint || mkdir -p /opt/etc/cloudprint
                        if [ -f $AUTHFILEOPT ]; then
                                cp $AUTHFILEOPT $AUTHFILEROOT
                        else
                            echo "No account file found, running now to set up your account file."
                            sleep 3
                            echo "You need a Google account set up, with a Google ID"
                            echo "As the prompts appear below, enter the following:"
                            echo "1.  your Google username followed by ENTER,"
                            echo " "
                            echo "2.  your Google password followed by ENTER,"
                            echo " "
                            echo "3.  then wait either 30 seconds or until"
                            echo "    the Google server to responds with some sort of message."
                            echo "    THEN enter a control-c  (^c)"
                            echo " "
                            echo "You will see some python error messages as the process is killed."
                            echo "Once this process has terminated, initiate the cloudprint-daemon"
                            echo "again using the 'start' flag, ..."
                            echo "like this:    /opt/etc/init.d/S90cloudprint-daemon start "
                            sleep 5
                            $PYBIN $DIR/cloudprint     
                            cp  $AUTHFILEROOT  $AUTHFILEOPT
                            exit 0
                        fi
                    else
                        test -d $AUTHFILEOPT || cp $AUTHFILEROOT  $AUTHFILEOPT
                    fi


                    if [ -f $PIDFILE ]; then
                        printf "cloudprint is already running with PID "
                         echo `cat $PIDFILE`
                    else
                        printf "Starting Google Cloud Print..."
                        $PYBIN $DIR/cloudprint -d -a $AUTHFILEROOT -p $PIDFILE
                        sleep 1
                        printf "started with PID "
                        echo `cat $PIDFILE`
                    fi
                ;;

                stop)
                        if [ -f $PIDFILE ]; then
                            printf "Stopping Google Cloud Print..."
                            kill `cat $PIDFILE`
                            sleep 1
                            if [ -f $PIDFILE ]; then
                                echo "FAILED!"
                            else
                                echo "Stopped"
                            fi
                        else
                            echo "cloudprint is not running!"
                        fi
                ;;

                restart)
                        if [ -f $PIDFILE ]; then
                            printf "Restarting Google Cloud Print..."
                            kill `cat $PIDFILE`
                            sleep 1
                            if [ -f $PIDFILE ]; then
                                echo "FAILED!"
                            else
                                echo "Stopped"
                            fi
                            sleep 1
                            $PYBIN $DIR/cloudprint -d -a $AUTHFILEROOT -p $PIDFILE
                            sleep 1
                            echo "cloudprint started with PID " `cat $PIDFILE`
                        else
                            echo "cloudprint is not running, so use the start option"
                        fi
                ;;


                *)
                        echo "Usage: cloudprint {start|stop|restart}"
                ;;
            esac
            exit 0

sudo chmod +x /etc/init.d/cloudprint
sudo update-rc.d cloudprint defaults


cloudprint [<option> ...]
-d              : enable daemon mode (requires the daemon module)
-l              : logout of the current google account
-p pid_file     : path to write the pid to (default cloudprint.pid)
-a account_file : path to google account ident data (optional)
-c              : establish and store login credentials, then exit
-f              : 'fast poll', if notifications aren't working
-u              : store username/password in addition to login token
                  to avoid authentication expiration
-i regexp       : include files matching regexp
-x regexp       : exclude filees matching regexp
                  regexp: a Python regexp, which is matched against the
                          start of the printer name
-h              : display this help


Include only the printers "lp" and "2up":

cloudprint -i lp -i 2up

Exclude all printers whose names start with "GCP-":

cloudprint -x GCP-

By default, all printers are included. For the include and exclude options, the argument is a regular expression which is matched against the start of the printer name.

For example, to include all printers whose names begin "lp":

cloudprint -i lp # includes both lp and lp2up

Este projeto já configura o cloudprint como um serviço em sistemas debian:

wget -c http://davesteele.github.io/cloudprint-service/deb/cloudprint_0.11-5.1_all.deb
wget -c http://davesteele.github.io/cloudprint-service/deb/cloudprint-service_0.11-5.1_all.deb
sudo dpkg -i cloudprint_0.11-5.1_all.deb
sudo dpkg -i cloudprint-service_0.11-5.1_all.deb

Google accounts with 2 step verification enabled need to use an application-specific password.

Authenticate cloudprintd.

sudo service cloudprintd login

You should see something like this.

Accounts with 2 factor authentication require an application-specific password
Google username: you@example.org
Password:
Added Printer MFC7360N

Start the Cloudprint daemon.

sudo service cloudprintd start

If everything is working correctly you should see your printer the following page:

https://www.google.com/cloudprint#printers


O URL específico do gadget não foi encontrado



ċ
cupscloudprint_20111108.deb
(9k)
Ademar Arvati Filho,
10 de nov de 2011 07:27
ċ
listcloudprinters.py
(6k)
Ademar Arvati Filho,
10 de nov de 2011 07:28
Comments