我想发送一个使用Google Cloud Print API打印的PDF文件。下面的代码将给我一个积极的信息,告诉我已生成一页。当我去检查结果时,我在空白页上打上了门。
如果我将打印内容保存在Google云端硬盘中,也会发生相同的结果。
unirest.post('https://www.google.com/cloudprint/submit')
.header('Authorization', 'Bearer ' + token)
.header("Accept-Charset", "utf-8")
.field('xsrf', xsrf_token)
.field('printerid', printerId)
.field('ticket', '{"version": "1.0", "print": {}}')
.field('title', 'Test from Simpe.li')
.field('contentType', 'application/pdf')
.attach('content', buffer)
.end(function (res) {
console.log(res);
});
Run Code Online (Sandbox Code Playgroud)
我知道我要发送的是PDF,因为当我更改
.field('contentType', 'application/pdf')
Run Code Online (Sandbox Code Playgroud)
至
.field('contentType', 'text/plain')
Run Code Online (Sandbox Code Playgroud)
我将获得53页文本,这是PDF文件的原始内容。
我做错了什么?
当我发送没有功能的打印机作业时,它的工作和打印:
<?php
$url = "http://www.google.com/cloudprint/submit?printerid=" . $printer_id . &output=json";
$post = array(
"printerid" => $printer_id,
"capabilities" => '',
"contentType" => "text/plain",
"title" => $title,
"content" => $docBytes
);
$post = http_build_query($post);
$ret = $this->processRequest($url, $post, "");
?>
Run Code Online (Sandbox Code Playgroud)
但现在我需要以A7格式信件打印信息.所以我用一些功能编写了这段代码:
<?php
$url = "http://www.google.com/cloudprint/submit?printerid=" . $printer_id . "&output=json";
$post = array(
"printerid" => $printer_id,
"capabilities" => array('psk:MediaSizeWidth' => '74000', 'psk:MediaSizeHeight' => '104700'),
"contentType" => "text/plain",
"title" => $title,
"content" => $docBytes
);
$post = http_build_query($post);
$ret = $this->processRequest($url, $post, "");
?>
Run Code Online (Sandbox Code Playgroud)
而且它不想打印.只是错误.也许有人知道如何正确地做到这一点?
我正在使用谷歌云打印与Android项目打印出PDF文件.我将文件存储在项目的assets文件夹中,当我打印时,它会显示"Document Missing".
这是我的代码
public void stevePrint(View view) {
Intent printIntent = new Intent(this, PrintDialogActivity.class);
//Cant find file, why?
File file = new File("/assets/steve.pdf");
printIntent.setDataAndType(Uri.fromFile(file), "document/pdf");
printIntent.putExtra("title", "Steve");
startActivity(printIntent);
Context context = getApplicationContext();
CharSequence text = "Sending to Google Cloud Print";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏!
我正在尝试生成一个简单的PDF并将其传递给Google Cloud Print,但是当我尝试将PDF打印到我的Google驱动器时没有任何反应.(登录工作)对于初学者,我如何验证我的PDF是完整有效的?我觉得我正在接受iText的话.
另外,我收到一些错误告诉我
public class PDFViewer extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
this.getWindow().setSoftInputMode
(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
super.onCreate(savedInstanceState);
InputStream object = this.getResources().openRawResource(R.raw.itextkey);
LicenseKey.loadLicenseFile(object);
File root = Environment.getExternalStorageDirectory();
File f = new File(android.os.Environment.getExternalStorageDirectory()
.getAbsolutePath() + java.io.File.separator + "HelloWorld.pdf");
boolean externalStorageAvailable = false;
boolean externalStorageWriteable = false;
String state = Environment.getExternalStorageState();
// if we can read and write to storage
if (Environment.MEDIA_MOUNTED.equals(state)) {
externalStorageAvailable = true;
externalStorageWriteable = true;
}
// else if we can read but cannot write
else if …Run Code Online (Sandbox Code Playgroud) 我在使用Android 4.3的Nexus 7第2版上遇到了Google云打印问题.我在我的应用程序中使用示例代码,它在许多Android设备上工作正常,除了Nexus 7,也许还有一些其他设备与android 4.3.
一切正常,直到我得到这个页面.

我之前选择'打印到谷歌驱动器'.然后,如果点击打印按钮没有任何反应......没有任何关于开始新工作或其他事情的消息.
也许有人可以给出一些建议.非常感谢.
我在我的Android应用程序中使用Google Cloud Print.为此,我在谷歌云上注册了我的打印机,而在打印命令时,它给了我在谷歌云上打印的注册打印机列表.
但是,我怎么能给出如下信息:"请在Google云上注册您的打印机",,,如果用户没有在云上注册他/她的打印机?
这意味着,我怎么知道,Google Cloud上没有以编程方式注册的打印机?
PrintHelper printHelper = new PrintHelper(QRCodeListActivity.this);
printHelper.setScaleMode(printHelper.SCALE_MODE_FIT);
printHelper.printBitmap("Print Bitmap", result);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google Cloud Print(GCP)API,但无法使其正常运行。也许我对工作流程的理解不正确,因为这是我第一次使用Google API,请帮助我了解如何使其工作。
初步考虑:
我到底想要什么:
为了进行首次测试,我希望获得有关打印机的所有信息。
我做了什么:
我选择了“应用程序类型:Web”,还配置了对源和重定向到本地主机的限制。
我在https://www.google.com/cloudprint中手动添加了打印机,并进行了打印PDF的测试,一切正常。
我在reactJS中创建了一个项目,以获取我添加的打印机的信息。
零件:
说明:
我正在使用一个组件react-google-login来轻松获取用户accessToken:https : //github.com/anthonyjgrove/react-google-login
该组件仅获取访问令牌并将其保存在localStorage中的变量中googleToken,它绘制一个按钮以调用函数以获取有关打印机的信息。
码:
import React, { Component } from 'react'
import GoogleLogin from 'react-google-login';
import { connect } from 'react-redux'
import { getPrinters } from '../actions/settings'
class Setting extends Component {
responseGoogle(response) {
const accessToken = response.accessToken
localStorage.setItem('googleToken', accessToken)
}
render() {
return (
<div>
<GoogleLogin
clientId="CLIENT_ID_REMOVED_INTENTIONALLY.apps.googleusercontent.com"
buttonText="Login"
onSuccess={this.responseGoogle}
onFailure={this.responseGoogle} …Run Code Online (Sandbox Code Playgroud)