Skip to main content

file convert pdf

Converts the specified file to PDF using Microsoft Graph

Usage

m365 file convert pdf [options]

Options

-s, --sourceFile <sourceFile>

Local path or full URL to the source file to be converted to PDF

-t, --targetFile <targetFile>

Local path or full URL to where the generated PDF file should be saved

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is options.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.

--verbose

Runs command with verbose logging.

--debug

Runs command with debug logging.

Remarks

To convert a local file to PDF, CLI will temporarily upload the file to a document library. If you're using app-only authentication, CLI will upload the file to the default document library in the root site collection on your tenant. If you're authenticated as a user, CLI will upload the file to the default document library in your OneDrive for Business. After the conversion, CLI will remove the uploaded file.

If you choose to store the converted file in a document library, CLI will store the converted PDF file temporarily in the temp folder on your computer. After the PDF file has been uploaded to the location you specified, CLI will remove the temporary file.

If the conversion process fails, CLI will attempt to clean up the temporary files (the source file uploaded to your tenant, if you're converting a local file to PDF, and the converted PDF file on your disk if you chose to upload the converted file to your tenant). If removing the temporary files fails, you will need to clean them up yourself. CLI will list the URL and/or path of the files to remove.

Examples

Converts local file to PDF and stores the converted file on the disk

m365 file convert pdf --sourceFile file.docx --targetFile file.pdf

Converts local file to PDF and uploads the converted file to a document library

m365 file convert pdf --sourceFile file.docx --targetFile "https://contoso.sharepoint.com/Shared Documents/file.pdf"

Converts file from a document library to PDF and saves the converted file to disk

m365 file convert pdf --sourceFile "https://contoso.sharepoint.com/Shared Documents/file.docx" --targetFile file.pdf

Converts file from a document library to PDF and saves the converted file to the same document library

m365 file convert pdf --sourceFile "https://contoso.sharepoint.com/Shared Documents/file.docx" --targetFile "https://contoso.sharepoint.com/Shared Documents/file.pdf"

Response

The command won't return a response on success.

CTRL + M