Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found <a href="https://code.google.com/p/java-printing-facade/source/browse/trunk/printing-facade-googlecloud/src/main/java/dk/apaq/printing/googlecloud/GoogleCloudPrintPlugin.java?r=65" rel="nofollow">this</a> link and it helps me</p> <p><strong>ADD:</strong></p> <pre class="lang-java prettyprint-override"><code>@Override protected Void doInBackground(Void... params) { try { DefaultHttpClient httpclient = new DefaultHttpClient(); String user = "user@gmail.com"; String pass = "password"; String source = "Cloud%20Printing%20Test"; HttpGet authGet = new HttpGet( "https://www.google.com/accounts/ClientLogin?accountType=HOSTED_OR_GOOGLE&amp;Email=" + user + "&amp;Passwd=" + pass + "&amp;service=cloudprint&amp;source=" + source); HttpResponse httpResponse; httpResponse = httpclient.execute(authGet); String authResponse = EntityUtils .toString(httpResponse.getEntity()); String authKey = authResponse.substring(authResponse .indexOf("Auth=") + 5); authKey = authKey.replace("\n", ""); MyLog.d(TAG, "Auth key: " + authKey); HttpPost printPost = new HttpPost( "https://www.google.com/cloudprint/submit?output=json"); printPost.setHeader("Authorization", "GoogleLogin auth=" + authKey); printPost.setHeader("X-CloudPrint-Proxy", source); List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); nameValuePairs.add(new BasicNameValuePair("printerid", "ID")); nameValuePairs.add(new BasicNameValuePair("title", "TEST")); nameValuePairs.add(new BasicNameValuePair("capabilities", "{capabilities=[]}")); nameValuePairs.add(new BasicNameValuePair("content", "123")); nameValuePairs.add(new BasicNameValuePair("contentType", "text/plain")); printPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse printResponse = httpclient.execute(printPost); String lol = EntityUtils.toString(printResponse.getEntity()); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } </code></pre> <p>But now I can print only text. If i found solution how to print pdf - I'll post code here</p> <p><strong>ADD2:</strong></p> <p>This code send pdf files to print</p> <pre class="lang-java prettyprint-override"><code>File file = new File("file.pdf"); FileBody fb = new FileBody(file); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); builder.addTextBody("printerid", "ID"); builder.addTextBody("title", "TEST2"); builder.addTextBody("capabilities", "{capabilities=[]}"); builder.addTextBody("contentType", "application/pdf"); builder.addPart("content", fb); printPost.setEntity(builder.build()); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload