web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Generate PDF for multi...
Power Apps
Answered

Generate PDF for multiple gallery items

(0) ShareShare
ReportReport
Posted on by 47

Hello,

I'm trying to build an parts approval app where users can approve or reject parts and download a PDF report for these items. I've reached a point where I can generate a report for one gallery item using Shane Young's process (linked below) where you send the selected item to an HTML text control and then use a flow to convert this to a PDF stored in SharePoint, but I want to add in the ability to generate multiple reports at once. 

 

My intension is for the user to select the items they need from a gallery with a checkbox control which adds that item to a collection. I've tried finding a way to send each of the items in the collection to the HTML Text control but nothing I've tried has worked.

 

I have found another post which seems to be about the same problem (linked below), but I've not been able to get this to work. The commenter says to use the JSON function on the collection, but this just returns an error for me saying "The JSON function cannot serialize tables / objects with a nested property called '{Attachments}' of type 'Table {Attachment}'.

 

This is my first project working with PowerApps and Power Automate, so any help would be greatly appreciated.

 

Due to internal requirements, every single item needs it's own report so a table wouldn't be suitable.

 

Create a PDF from SharePoint Data using Power Apps and Power Automate flow for free - YouTube

Solved: Generate a PDF of multiple selected list items in ... - Power Platform Community (microsoft.com)

Categories:
I have the same question (0)
  • SanmeshG Profile Picture
    1,947 Moderator on at

    Hi @Evil_Zoidberg  ,

     

    You want to create ,

    1. A single PDF from multiple gallery items or 

    2. Create Multiple PDFs(One PDF for each gallery Item)

     

    1. the method shared in the link (article) works fine , while sending the collection you can drop the attachment column from your collection and send the collection to your flow and then generate the schema and use the parse JSON action.

    2. If you want to generate multiple PDFs then your collection will have multiple records selected by the user from checkbox in the gallery. So your flow will be the same till the parse JSON action but after that you have to create the PDFs inside of an apply to each loop , which will iterate as many times the number of rows in your array (your collection in pwerApps). and create the PDFs. This will work fine for 1 or more PDFs. 

     

    Hope this helps!

     

    If this answers your question please mark this as a solution.

  • OH-07080958-0 Profile Picture
    47 on at

    Hi @SanmeshG 

     

    Thanks for the reply. I want to create one PDF showing gallery items.

     

    I've used dropcolumns to remove the Attachments columns from the collection which is allowing me to get the JSON value.

     

    I've started to put the Flow together. For the Parse JSON step, I've used ask in PowerApps for the content, and generated the Schema from the JSON value I calculated in the app.

     

    I'm not sure what to do with the Select and Create HTML Table steps. For the Select step, I'm assuming I select each column I want from the Parse JSON step for From, I'm not sure what would be needed for the key and value for Map.

     

    Would the HTML table just be the output from Select?

    Untitled.png

  • SanmeshG Profile Picture
    1,947 Moderator on at

    Hi @Evil_Zoidberg ,

     

    Yes you can use the body of parse json as an input for your select operation or for your create html action. Select operation is needed only if you want some specific columns and not all from your parse json action body(array).

     

    You can skip the select operation completely and give the names in the create html table action directly select custom and give the header names(if you want header names with spaces copy and paste them from notepad with spaces as spaces while typing may not be allowed). In the Value section write an expression to get the value associated with the column. For eg. 

    Here the FirstName is my column name(this should be as per the body of the parse json action.)

    item()?['FirstName']

     

    Additionally if you are selecting values from object you should write the expression as below. Here Manager is a User or Group type of column and we want to get the DisplayName property from the Manager object in the array. (SP People Picker).

    item()?['Manager/DisplayName']

     

    Hope this helps!

  • OH-07080958-0 Profile Picture
    47 on at

    Thanks @SanmeshG,

     

    I've been able to get the flow working so it creates the PDF file, but the problem is that I need each item to load as a separate report rather than in a table. As I already have a report format that I am happy with saved in an HTMLtext object, is there anyway to generate a separate report for each selected item.

  • SanmeshG Profile Picture
    1,947 Moderator on at

    Hi @Evil_Zoidberg  ,

     

    Separate report here I am assuming is a separate PDF file for each item that user selects from the PowerApps gallery.

    Follow point 2 from the first answer. You need to iterate on your JSON array and generate a new file for each item.

    1. Take JSON array as an input for an apply to each. add the same actions( create HTML table , create html  file , convert html to PDF and create PDF , but this time inside apply to each , make sure that you make the instance inside of apply to each an array and not object so adding [ and ] will help )

     

    parse_json.png

     

    Hope this helps!

  • OH-07080958-0 Profile Picture
    47 on at

    Hi @SanmeshG,

     

    It's not separate pdfs I need, but  for every item having it's own certificate with the part information and approval status shown, this would then be repeated for each items that's been selected.

     

    So essentially the final PDF will show something like:

     

    Part 1

    Supplier

    Approval Status

     

    Part 2

    Supplier

    Approval Status

     

    With the certificate for each part on it's own page. There are 28 separate bits of information I need to show along with a common disclaimer, company information and logo and the approver's signature. 

     

    Apologies for the confusion, I probably haven't been entirely clear with what I'm looking for.

  • SanmeshG Profile Picture
    1,947 Moderator on at

    Hi @Evil_Zoidberg ,

     

    Okay so you can create the html in a compose action and pass the values from your JSON and then create html file , convert to PDF file and then create PDF file.

  • OH-07080958-0 Profile Picture
    47 on at

    Hi @SanmeshG 

     

    I'm not familiar with Compose. When I've added one of the outputs from the parse JSON function, it gets wrapped in an apply to each function, adding all of the outputs from parse JSON makes no difference to the outcome.

     

    Am I doing something wrong here?

  • Verified answer
    OH-07080958-0 Profile Picture
    47 on at

    So I've not had a response in a while, but if anybody else comes across this later I have figured this out and it's a lot simpler than I initially realised.

     

    All you need to do is wrap your HTML text in the concat function, using your collection as the data source. This will repeat the HTML format for each item in the collection. This also works with the export to PDF flow.

     

    For example:

    Concat([yourcollection],
    "<!DOCTYPE html>
    <html>
    <body>

    <p><b><Approval Number: </b>" & [columnname1] & "</p>
    <p><b>Part Number: </b>" & [columnname2] & "
    </body>
    </html>")

     

    You'll need to remove the square brackets from the collection and column names.

  • Asa7a2 Profile Picture
    2 on at

    How to save pdf with a name/id number that is in my gallery?
    the ones I have seen save with a default name

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard