问题
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