我在一个蓝色的功能,其中我需要转换PDF到Excel的工作。我正在使用Adobe PDF Tools API进行转换。PDF在我的azure存储帐户中,我使用datalake文件客户端访问它,并读取内存流中的内容。然后我使用API,代码如图所示。
await file.ReadToAsync(memoryStream);
Credentials credentials = Credentials.ServiceAccountCredentialsBuilder()
.FromFile("pdftools-api-credentials.json")
.Build();
Adobe.DocumentServices.PDFTools.ExecutionContext executionContext = Adobe.DocumentServices.PDFTools.ExecutionContext.Create(credentials);
ExportPDFOperation exportPdfOperation = ExportPDFOperation.CreateNew(ExportPDFTargetFormat.XLSX);
FileRef sourceFileRef = FileRef.CreateFromStream(memoryStream, ExportPDFOperation.SupportedSourceFormat.PDF.GetMediaType());
exportPdfOperation.SetInput(sourceFileRef);
FileRef result = exportPdfOperation.Execute(executionContext);现在,当我运行这段代码时,我得到了以下错误:
“收到请求的错误响应:发送请求时出错。响应提前结束。”
代码在C#中。
有人能帮帮忙吗?提前谢谢你
发布于 2021-04-09 00:35:09
我得到了同样的错误,当导出一个pdf到图像。
我将Adobe.DocumentServices.PDFTools NuGet包从版本1.3.0降级到了1.2.0,它给出了一个更有用的错误消息:“输入文件是一个零长度文件。”
添加这个为我修复了它。
memoryStream.Position = 0;https://stackoverflow.com/questions/66952545
复制相似问题