Skip to main content

Notifications

Convert Office Files to PDF in Power Apps

Implementation Steps

  1. Store Files in SharePoint Document Library
    Ensure your Word, Power Point, and Excel files are stored in a SharePoint document library. This library will serve as the data source for the Power App.
  2. Create a Connection in Power Apps
    1. Open Power Apps and create a new app or open an existing one.
    2. Go to the Data tab and click Add data.
    3. Search for SharePoint and select it.
    4. Connect to your SharePoint site and select the document library where your files are stored.
  3. Create a Gallery Connected to SharePoint
    1. Add a Gallery control to your app.
    2. Set the Items property of the Gallery to the SharePoint document library connection you created.
    3. Customize the Gallery to display relevant information, such as the document title or name.
      1. Example: Filter the gallery Items to show only Word, Excel, and PPTs
        Filter(Documents, Last(Split('File name with extension', ".")) in ["docx", "xlsx", "pptx"])
        maqsoftware_0-1718343397864.png

         

  4. Covert and download PDF version of files
    1. Add a Download button in gallery
    2. In OnSelect property of button, use below expression

      Download(Substitute(ThisItem.Thumbnail.Large, "/thumbnail", "/pdf"))

      maqsoftware_1-1718343422855.png
  5. Output: 

    Click Download button to get the PDF version of Word, Excel, or PPT files.

    maqsoftware_2-1718343440940.png

     

Comments

*This post is locked for comments

  • AndyHoll Profile Picture AndyHoll
    Posted 20 Jun 2024 at 06:55:46
    Convert Office Files to PDF in Power Apps

    @maqsoftware that's really helpful - thanks very much! 

  • maqsoftware Profile Picture maqsoftware 5
    Posted 20 Jun 2024 at 04:47:57
    Convert Office Files to PDF in Power Apps

    @AndyHoll

    First, ensure the documents are accessible in a SharePoint library, OneDrive, or any other cloud storage service that PowerApps can connect to.

    Enable Offline Capability:

    PowerApps has offline capabilities that allow data to be cached and used when there is no network connection. This is done using the LoadData and SaveData functions.
    Load Documents on App Load:

     

    Use the OnStart property of your app to load the documents into a collection. Here’s an example code snippet:
    Handle Document Viewing:

    To view documents offline, you need to download them to the device. Use the Download function to cache the document locally.

    For example, when a user selects a document to view, you can download it as follows:

    Display Offline Documents:

    Use a gallery or a list to display the cached documents. When the app is offline, use the LoadData function to load the documents from the local storage:
    Check Connectivity:

     

    Use the Connection.Connected property to check if the device is online or offline, and switch between online and offline data sources accordingly.

     

    Here is a more detailed example to guide you through setting up offline capabilities for documents in PowerApps:

    codeLoadData(LocalDocuments, "DocumentsCollection", true);

     

    / Assuming the document URL is stored in the variable DocumentURL
    Download(DocumentURL);

     

    // Assume you have a document list in SharePoint named "Documents"
    ClearCollect(LocalDocuments, Documents);
    SaveData(LocalDocuments, "DocumentsCollection");

  • AndyHoll Profile Picture AndyHoll
    Posted 17 Jun 2024 at 07:44:40
    Convert Office Files to PDF in Power Apps

    Awesome @maqsoftware, is there a way to make the documents available offline within the app too?

  • ramanujama Profile Picture ramanujama 51
    Posted 17 Jun 2024 at 05:44:06
    Convert Office Files to PDF in Power Apps

    I am  using Power Automate to do the same. This option is more easy now. Thank you.

  • allamram Profile Picture allamram
    Posted 17 Jun 2024 at 05:41:53
    Convert Office Files to PDF in Power Apps

    Easy way. Thanks you.