1

I'm attempting to use Sharepoint 2016 (RTM) to convert a PPTX to PDF. Whenever I attempt a conversion, I receive the following error:

AsyncResult operation exceeded timeout of 00:05:00.

I do notice that when I start a conversion, the SQL Server and Windows Server App Fabric processes seem to use higher CPU (~50%) than normal (~1%). Also, each time a conversion is initiated, a new folder appears under C:\ProgramData\Microsoft\SharePoint\PowerPointConversion\<some GUID>\<MYDOMAIN_MyUser>\, containing my original source PPTX, and a folder called 00000000000000000000000000000012 with no contents. (See image below)

empty folder that appears after initiating a conversion

I'm using IronPython, but I've also tried and received the same results with a C# rewrite.

Things I've tried based on other questions (e.g. here)

  • Checked that PowerPoint automation services is running
  • Checked that my code is running as a user with Farm Administrator privileges
  • Checked that my code is running on the server that Sharepoint resides
  • Checked that my code is running as a user with local Administrator privileges
  • Ensured that my user has memberships of the WSS_ADMIN_WPG, WSS_WPG, and WSS_RESTRICTED_WPG_V4 groups
  • Ensured that my user has all server roles available to it in SQL Server
  • Ensured my user is the one running the application pool in IIS containing the PowerPointConversion
  • Ensured my server is not a Domain Controller and that that resides on another machine.
  • Ensure that my user has explicit full control (r/w etc) on the C:\ProgramData\Microsoft\SharePoint\PowerPointConversion folder.

Here's my code:

import clr
import os
import sys

from System.IO import FileStream, MemoryStream, FileMode, FileAccess

clr.AddReference("Microsoft.Sharepoint")
from Microsoft.SharePoint import SPSite, SPServiceContext

clr.AddReferenceToFileAndPath("C:\\Windows\\Microsoft.NET\\assembly\\GAC_MSIL\\Microsoft.Office.Server.PowerPoint\\v4.0_16.0.0.0__71e9bce111e9429c\\Microsoft.Office.Server.PowerPoint.dll")  # noqa
from Microsoft.Office.Server.PowerPoint.Conversion import PdfRequest

OUR_SHAREPOINT_SITE_URL = "http://name_of_my_sharepoint_machine/"


def convert_powerpoint_to_pdf(input_office_file_path, output_pdf_file_path):
    with SPSite(OUR_SHAREPOINT_SITE_URL) as site:
        with site.OpenWeb() as web, \
            FileStream(input_office_file_path, FileMode.Open) \
                as office_file_contents, \
                MemoryStream() as pdf_contents:
            try:
                # The PowerPoint automation services API irritatingly requires
                # the input file extension
                extension = os.path.splitext(input_office_file_path)[1]
                request = PdfRequest(office_file_contents, extension,
                                     pdf_contents)

                # The callback for this method is none, and we capture the
                # output in the result object
                result = request.BeginConvert(
                    SPServiceContext.GetContext(site), None, None)

                request.EndConvert(result)
                with FileStream(output_pdf_file_path, FileMode.Create,
                                FileAccess.ReadWrite) as output_file_stream:
                    pdf_contents.WriteTo(output_file_stream)
                    # just to be safe
                    office_file_contents.Close()
                    return "Yay"

            except Exception as e:
                return "PPT Conversion failed with error message:\n{}".format(
                    str(e))

if __name__ == "__main__":
    print(convert_powerpoint_to_pdf(
        input_office_file_path=sys.argv[1],
        output_pdf_file_path=sys.argv[2]))

Which gives the following output:

C:\Windows\system32>ipy64 C:\sharepoint_example.py C:\pptx.pptx C:\pptx.pdf
PPT Conversion failed with error message:
AsyncResult operation exceeded timeout of 00:05:00

C:\Windows\system32>

I can also supply the trace log on request if needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.