Google app engine Google转换API不会将文本转换为图像png
嗨 我试图使用google转换api将html文本转换为png格式 我尝试使用blob store api将转换结果存储到,但看到它没有渲染图像。代码是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
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());
}
你说的“看不出图像”是什么意思?到底发生了什么?嗨,它显示的符号就像一个破碎的图像。这是答案吗?