cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Rajesh
Advocate II
Advocate II

Generate PDF from SharePoint list item

Hi

 

Is it possible to generate PDF from a SharePoint list item with all the form data when an item is saved into SharePoint?

 

I've looked into the option RenderListDataAsStream. but I guess this only converts word documents into stream

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-lists-and-list-items-with-re...

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
v-yamao-msft
Community Support
Community Support

Hi @Rajesh,

 

Do you want to generate a PDF file from SharePoint list items?

Please consider using the OneDrive for Business action Convert file to convert an HTML file to PDF.

Please take the following flow for a reference.

The flow is triggered by When an item is created in a SharePoint list.

Get items from the list.

Create an HTML table from the list.

Add the action Create file to create an .htm file in OneDrive for Business. Set its File name as ListB.htm.

Add the action Convert file to convert the file to pdf.

Last, create a .pdf file with a new name.

A screenshot for your reference.

1.PNG

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

44 REPLIES 44
v-yamao-msft
Community Support
Community Support

Hi @Rajesh,

 

Do you want to generate a PDF file from SharePoint list items?

Please consider using the OneDrive for Business action Convert file to convert an HTML file to PDF.

Please take the following flow for a reference.

The flow is triggered by When an item is created in a SharePoint list.

Get items from the list.

Create an HTML table from the list.

Add the action Create file to create an .htm file in OneDrive for Business. Set its File name as ListB.htm.

Add the action Convert file to convert the file to pdf.

Last, create a .pdf file with a new name.

A screenshot for your reference.

1.PNG

 

Best regards,

Mabel

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

How do I get the content of the SharePoint list item into PDF instead of the list of items?

You create the html first by adding the required content from list item and then save in one drive and convert to pdf as shown in the flow

Anonymous
Not applicable

I Need help with this. My converted PDF contains only the first header and than data in html, 

Anonymous
Not applicable

I've got this working but struggling to put a logo in to the html file? I've tried storing the logo image in the site assets folder on the sharepoint site and referring to the full path in the <img> tag, I've also tried storing the image file in the same folder in OneDrive that the files are generated in but all I get in the html and pdf file is the unknown picture square?

Help please?

Anonymous
Not applicable

If anyone is interested in this, the answer (thanks to Shane Young) is to put the picture in OD4B, use a get file content action, then store a DataURI(Body('Get_File_Content')) expression into a variable and then put that variable into the html

Youtube video here: https://www.youtube.com/watch?v=2rfAQe1kK8M

I tried using this and creating from a Task List.  Running into an issue where i cant choose the "Issue Status Value" so from the dynamic info.  Any ideas?  We only want a DPF to be created if the issue has been closed.

Hi Mabel,

 

Does it work with List items which contains attachements (images, files etc.) too?

 

Juliana


@v-yamao-msft wrote:

Hi @Rajesh,

 

Do you want to generate a PDF file from SharePoint list items?

Please consider using the OneDrive for Business action Convert file to convert an HTML file to PDF.

Please take the following flow for a reference.

The flow is triggered by When an item is created in a SharePoint list.

Get items from the list.

Create an HTML table from the list.

Add the action Create file to create an .htm file in OneDrive for Business. Set its File name as ListB.htm.

Add the action Convert file to convert the file to pdf.

Last, create a .pdf file with a new name.

A screenshot for your reference.

1.PNG

 

Best regards,

Mabel



@v-yamao-msft wrote:

Hi @Rajesh,

 

Do you want to generate a PDF file from SharePoint list items?

Please consider using the OneDrive for Business action Convert file to convert an HTML file to PDF.

Please take the following flow for a reference.

The flow is triggered by When an item is created in a SharePoint list.

Get items from the list.

Create an HTML table from the list.

Add the action Create file to create an .htm file in OneDrive for Business. Set its File name as ListB.htm.

Add the action Convert file to convert the file to pdf.

Last, create a .pdf file with a new name.

A screenshot for your reference.

1.PNG

 

Best regards,

Mabel


 

I've tried following the instructions listed and get the following error for "Create HTML table" but not really sure how to fix. Any ideas?

BadRequest. The 'from' property value in the 'table' action inputs is of type 'Null'. The value must be of type 'Array'.
Anonymous
Not applicable

Hi, what have you put as the input for the create HTML table action? You should use the value from the Get Items action above it

I was able to get it to work now but the output looks really bad.  I'm really just needing to have a single output to look like a nice report once the request has been completed.

I did this using the MS word connector. In my app I have an icon sor the selected record in my gallery. That gallery is a share Point List. Once the user click in the icon a flow will generate a word document in my onedrive using a word template and populating the data form the sharepoint, then it will convert a PDF and email me that PDF. If you think that this suits your needs chech the MS word connector.

 

Regards

Sounds interesting, I'll have to take a look.  I'm wondering how you set up your work template.  Would you be abe to share your template? I found a few things online but also saw that there can be issues with certain columns being used. 

 

Also, do you need to create and share a specific folder in your OneDrive so that if someone else presses the button it can use the word document in there? 

This guy teach how to create the MS Word template using the Developer tab, is easy.

 

Once you have created the word template *.docx. Create a folder in your onedrive.

Place the template in that folder.

Create a subfolder for the documents to be generated using that template. 

Create the flow.

Add in your powerapp an icon that triggers the flow.

 

Here is the video for the word connector:

 

https://www.youtube.com/watch?v=Zzm965PlYl0

 

And read this post, I have some screen shots for the process. And I have to say thanks to @Pstork1, I was able to acomplish this.

 

If you get stuck at some point let me know. I will try to do my best.

 

Regards.

 

https://powerusers.microsoft.com/t5/General-Flow-Discussion/MS-Word-Connector/td-p/350262

 

 

Thanks so much everyone is so helpful here.

Could you please ellaborate your work in converting the user input to word document followed by pdf?

Which part do you need?

 

I have running mine but, currently I am looking for another alternative, I don't want to use a premium connector for a feature that should be included.

 

Let me know and I will help you out.

 

Thx  

Is there a way to change the name of the file each time you run so it doesn't just override the last one?  If I missed that, I apologize.

thanks!

Hi, I think that probably the best way is to save the file name including the current date. By doing this you will never get the same file name.

 

Make sense?

 

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,399)