Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Experimental Features
Unanswered

Download PDF directly From PowerApps

(2) ShareShare
ReportReport
Posted on by 752
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, """","")}]
  • Sam_Fawzi Profile Picture
    501 Super User 2025 Season 1 on at
    Download PDF directly From PowerApps
    Hey @ 
     
    Can you try change the Attachment Control Format to the below 
     
    Table({Name: "amendment.pdf", Value: Mid(pdfContent, 2, Len(pdfContent) - 2)})
    
     
  • stampcoin Profile Picture
    2,962 on at
    Download PDF directly From PowerApps
    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.
  • rpersad Profile Picture
    752 on at
    Download PDF directly From PowerApps
     
    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
    2,962 on at
    Download PDF directly From PowerApps
    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
    752 on at
    Download PDF directly From PowerApps
    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
    2,962 on at
    Download PDF directly From PowerApps
    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
    752 on at
    Download PDF directly From PowerApps
     
    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
    2,962 on at
    Download PDF directly From PowerApps

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1

Featured topics