Convert a encrypted Word docx file to PDF using API?

Yamilla Manjko 6 Reputation points
2022-11-08T18:09:07.937+00:00

Is there a way to convert an encrypted Word docx with its confidentiality set confidential to PDF using Microsoft Graph or some other API?
I have tried using the MS Graph Convert Content (https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=http) but it gives me an error

{"error":{  
  "code": "notSupported",  
  "message": "Error from Office Service. Url=https://wordcs.officeapps.live.com/document/export/pdf HttpCode=UnsupportedMediaType cert=subject:;thumbprint: ResponseHeaders=X-ErrorCode: WordDocumentIsIRMProtected\r\nX-ClientCorrelationId: xxxx\r\nX-ServiceCorrelationId: xxxx\r\nX-ErrorCategory: NotSupported\r\nX-IsRetriable: False\r\nX-ConversionTimeInMs: 281.2625\r\nX-FileDownloadTimeInMs: 1171.8919\r\nCache-Control: private\r\nDate: Mon, 07 Nov 2022 19:02:20 GMT\r\nServer: Microsoft-IIS/10.0\r\nX-AspNet-Version: 4.0.30319\r\nX-Powered-By: ASP.NET\r\n",  
  "innererror": {  
    "code": "fileIRMProtected"  
  }  
}}  
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,364 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,707 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. HarmeetSingh7172 4,811 Reputation points
    2022-11-08T21:49:24.21+00:00

    Hello @Yamilla Manjko

    Thanks for reaching out!

    As far as I know, currently Graph API does not support conversion of an encrypted Word document into PDF format. You first need to remove the encryption of the docx file, & then convert it into PDF format.

    Endpoint- GET /drive/items/{item-id}/content?format=pdf

    Available format options in v1.0-
    https://learn.microsoft.com/en-us/graph/api/driveitem-get-content-format?view=graph-rest-1.0&tabs=http#format-options

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments