javascript - 使用 MS Graph 将 excel 转换为 pdf 返回错误文件
问题描述
我正在使用 MS Graph API 将 excel 转换为 pdf。
但是我从 MS Graph API 获得的 pdf 文件与我从打印 Excel 获得的文件不同。
例如:我的 excel 只有 2 页,当我使用 excel 打印 PDF 时,我正好得到 2 页,但是当我使用 MS Graph API 将 excel 转换为 pdf 时,我的 pdf 文件有 4 页。
这是我将 excel 转换为 pdf 的 js 代码,只需将 http 请求作为文档发送:
export const convertPDF = async (token: string, fileID: string): Promise<ArrayBuffer> => {
return new Promise((resolve, reject): void => {
const baseUrl = `https://graph.microsoft.com/v1.0/me/drive/items/${fileID}/content?format=pdf`;
axios
.get(baseUrl, {
headers: {
Authorization: `Bearer ${token}`,
},
responseType: "arraybuffer",
})
.then((response): void => {
resolve(response.data);
});
});
};
这是我的 excel 文件(2 页):SocialInsuranceDisqualification (2).xlsx
这是来自 MS Graph API 的 pdf 文件(4 页):416d334b-00db-4535-a56e-bf9254e6a56e.pdf
- 这是使用 Excel 打印功能的 pdf 文件:(2 页):SocialInsuranceDisqualification (2).pdf
解决方案
推荐阅读
- r - 为 geom_violin 图增加意义
- java - 整数模字符(也是一个数字)给出不正确的结果
- ios - 无法在 iPad 上水平显示 AngularJS 材质复选框,但可以在桌面上使用
- php - 如何将单个文本区域中的多个值发布到 MySQL 中的 where 子句
- c# - 如何验证中继器中的所有复选框都已选中
- python - 当我在不同位置安装了多个 python 时,如何升级特定的 python 库?
- swift - 如何在 Swift 中使用 CFNumberFormatterRoundingMode
- matlab - 删除 SLURM 集群上的 parpool 对象行为
- ios - 在自定义类中获取按钮触摸事件类型
- gnuplot - 是否可以通过 GNUPLOT 中的数字更改绘图中的点?