我有一个使用Google Cloud Print API(https://github.com/jittagornp/GoogleCloudPrint)打印pdf的Java应用程序。在大多数情况下,它的工作方式就像一个魅力,但偶尔(大约100个中的100个)它会给出一个错误,它看起来就像这样的“Detgårintegothändringarieett avslutat jobb”。 它粗略地翻译成英文,上面写着:“无法改变已完成的工作” 踢球者是每次打印页面完美打印,有或没有错误。
每次调用GCP代码都是这样的:
public static SubmitJobResponse submitPrintJob(String filename, String type){
String jsonTicket;
String printerId;
SubmitJobResponse response = null;
String jobtitle;
jobtitle = filename.substring(filename.lastIndexOf('/') + 1);
// Login to GCP
GoogleCloudPrint cloudPrint = gcpLogin();
jsonTicket = "{'version':'1.0','print':{'vendor_ticket_item':[],'color':{'type':1},'copies':{'copies':4}}}";
printerId = session("printerlabel");
try {
// Get file as byte array
Path path = Paths.get(filename);
byte[] content = Files.readAllBytes(path);
Gson gson = new Gson();
Ticket ticket = gson.fromJson(jsonTicket, Ticket.class);
String json = gson.toJson(ticket);
//create job
SubmitJob submitJob = new SubmitJob();
submitJob.setContent(content);
submitJob.setContentType("application/pdf");
submitJob.setPrinterId(printerId);
submitJob.setTicket(ticket);
submitJob.setTitle(jobtitle);
//send job
response = cloudPrint.submitJob(submitJob);
Logger.debug("PrinterID => {}", printerId);
Logger.debug("submit job response => {}", response.isSuccess() + "," + response.getMessage());
if(response.isSuccess()) {
Logger.debug("submit job id => {}", response.getJob().getId());
}
cloudPrint.disconnect();
} catch (Exception ex) {
Logger.warn(null, ex);
}
return response;
}
API在GCP上使用“/ submit?output = json& printerid =”的调用,为什么它说我正在尝试更改已完成的作业 - 我没有提交作业ID - 只有打印机ID 。
如何摆脱这些错误的错误?