Converting excel to pdf returns wrong file using MS Graph

泪湿孤枕 提交于 2019-12-24 18:31:31

问题


I'm using MS Graph API to convert excel to pdf.

But the pdf file I get from MS Graph API is different from the file I get from printing of Excel.

For example: My excel has only 2 pages, when I use excel to print PDF, I get exactly 2 pages, but when I use MS Graph API to convert excel to pdf, my pdf file has 4 pages.

This is my js code to convert excel to pdf, just only send http request as document:

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);
      });
  });
};
  • This is my excel file (2 pages): SocialInsuranceDisqualification (2).xlsx

  • This is pdf file from MS Graph API (4 pages): 416d334b-00db-4535-a56e-bf9254e6a56e.pdf

  • This is pdf file from using printing function of Excel: (2 pages): SocialInsuranceDisqualification (2).pdf

来源:https://stackoverflow.com/questions/58831838/converting-excel-to-pdf-returns-wrong-file-using-ms-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!