Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine Google转换API不会将文本转换为图像png_Google App Engine_Data Conversion - Fatal编程技术网

Google app engine Google转换API不会将文本转换为图像png

Google app engine Google转换API不会将文本转换为图像png,google-app-engine,data-conversion,Google App Engine,Data Conversion,嗨 我试图使用google转换api将html文本转换为png格式 我尝试使用blob store api将转换结果存储到,但看到它没有渲染图像。代码是 Asset asset = new Asset( "text/html", "my name is vik".getBytes(), "testfile.html"); Document document = new Document(asset); Conversion conversion = new Conversion(do

我试图使用google转换api将html文本转换为png格式

我尝试使用blob store api将转换结果存储到,但看到它没有渲染图像。代码是

Asset asset = new Asset(
  "text/html", "my name is vik".getBytes(), "testfile.html");
  Document document = new Document(asset);
  Conversion conversion = new Conversion(document, "image/png");
  ConversionService service =
  ConversionServiceFactory.​getConversionService();
   ConversionResult result = service.convert(conversion);

   if (result.success()) {
// Get a file service
  FileService fileService = FileServiceFactory.​getFileService();
  // Create a new Blob file with mime-type "text/plain"
  AppEngineFile file = fileService.createNewBlobFile(​"image/png");
  boolean lock = true;
  FileWriteChannel writeChannel = fileService.openWriteChannel(​file, lock);
  PrintWriter out = new PrintWriter(Channels.​newWriter(writeChannel, "UTF8"));

  // Note: in most cases, we will return data all in one asset,
  // except that we return multiple assets for multi-page images.
  for (Asset ast : result.getOutputDoc().​getAssets()) {
  out.println(ast.getData());
  }
  out.close();

  // Now finalize
  writeChannel.closeFinally();
  log.info("Finished blob stored");
  } else {
  log.info(result.getErrorCode(​).toString());
  }

你说的“看不出图像”是什么意思?到底发生了什么?嗨,它显示的符号就像一个破碎的图像。这是答案吗?