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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Download PDF directly ...
Power Apps
Unanswered

Download PDF directly From PowerApps

(2) ShareShare
ReportReport
Posted on by 776
Not sure if anyone has tried this before but I am trying to enable the option for users to download a PDF version of a form created using HTML code.
 
Found this video on youtube https://youtu.be/PlBPCi4yXVs?si=YeuuU03xymEjIe72&t=828 which demonstrates this by using the PDF function with the attachment control.
 
However, when I select the attachment control I get the 404 error on my browser, see screenshot attached.
 
Here is the code for my button to generate the PDF blob:
Set(pdfContent, JSON(PDF(Container2),JSONFormat.IncludeBinaryData));
 
Here it my attachment control item property code:
[{Name: "amendment.pdf", Value: Substitute(pdfContent, """","")}]
Categories:
I have the same question (0)
  • stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
  • rpersad Profile Picture
    776 on at
     
    Thanks for the response did try using the code but the issue still persists
     
    For the button to convert the HTML to JSON in the PDF function I have tried:
    • Including the "ExpandContainers: true" in the function
    • Including the "ExpandContainers: false" in the function
    • Removing the "ExpandContainers" property in the function
     
    In the attachment control I have tried using the code below:
    • [{Name: "amendment.pdf", Value: pdfContent}]
    • {Name: "amendment.pdf", Value: pdfContent}
    • [{Name: "amendment.pdf", Value: Mid(pdfContent, 2, Len(pdfContent) - 2)}]
    • {Name: "amendment.pdf", Value: Mid(pdfContent, 2, Len(pdfContent) - 2)}
    • [{name: "amendment.pdf", value: Mid(pdfContent, 2, Len(pdfContent) - 2)}]
    • {name: "amendment.pdf", value: Mid(pdfContent, 2, Len(pdfContent) - 2)}
     
    Note: When I changed 'Name' and 'Value' to common letters nothing happened when I clicked the attachment control
  • stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
    Did you render the content (html) first in the container ?
    Do you understand 's explanation ?
    To make it clear, that case is not download from a real address.
  • rpersad Profile Picture
    776 on at
    I did put the HTML text into a container named Container2 as shown in the question. And in my case I also am not trying to download from a real address location of the file 
     
    Here is a screenshot of the data being saved in the pdfContent variable which was passed from my JSON function
  • stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
    How did you add the attachment control ?
    I share mine for your reference. ( My old control seems broken, I re-added the attachment control).
     
    Button: onselect =
    Set(
        pdfcontent,
        JSON(
            PDF(DataTable1,{DPI:60}),
            JSONFormat.IncludeBinaryData
        )
    );
    Navigate(Screen1)
     
    On Screen1:
    Attachment control, Items=
     
    {
        Name: "Test.PDF",
        value: Mid(
            pdfcontent,2,
            Len(pdfcontent) - 2
        )
    }
    click the file, it will download.
  • rpersad Profile Picture
    776 on at
     
    My button 'OnSelect' code is the same, I have my Html text in a container (Container2) and am referencing the container in the JSON function
     
    My Attachment control, 'Items' property was slightly different. I had a capital "V" for the value and had my code in square brackets '[ ]'. Tried updating it to match your code I am still getting the same error.
     
     
  • stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
    Have you tried to remove the attachment control, and add a new one.
    I had one broken and after re-add, it works.
    Your previous image shows correct ( pdfcontent).
    You have to use {} rather than [], the items need a table value, not array.
    The mid function is for removing the "", so the value doesn't contain it.
    try add a new one and feel free if you have any question.
  • Sam_Fawzi Profile Picture
    750 Super User 2025 Season 2 on at
    Hey @ 
     
    Can you try change the Attachment Control Format to the below 
     
    Table({Name: "amendment.pdf", Value: Mid(pdfContent, 2, Len(pdfContent) - 2)})
    
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard