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 / Same code works on PDF...
Power Apps
Answered

Same code works on PDF icon, but not on Button

(0) ShareShare
ReportReport
Posted on by 27
Hello,
 
In my PowerApps, I would like to send an email with PDF attachment, which is the whole content of EditForm.
 
In short, the code applied on a Submit Button not working. But the same code applied on PDF icon worked fine.
 
The story is...
I implemented a Submit Button at the first place. It worked fine with completed PDF attachment.
One week later, I revised something like title text. But not the logic of Submit Button.
When unit testing, it sent email successfully. But the PDF attachment was corrupted.
 
 
So, a PDF icon was created later for debug. I just copied the code from Submit Button to PDF icon.
It worked totally fine. Email sent with full PDF attachment.
 
 
Code snippet as below:
 
Office365Outlook.SendEmailV2(
    "jameskwong@somewhere.in.hk", // Recipient
    "testing testing why: Performance Assessment 2024 ... from PDF button of James Kwong (FA11111)", // Email subject
    "Performance Assessment 2024 PDF is generated from Power Apps", // Email body
    {
        Attachments: Table(
            {
                Name: "PerformanceAssessment2024.pdf",
                ContentBytes: PDF(
                    EditForm,
                    {
                        ExpandContainers: true,
                        Orientation: PaperOrientation.Portrait,
                        Size: PaperSize.A4,
                        Margin: "25mm"
                    }
                )
            }
        )
    }
);
 
In addition, I found the Power Apps Release was updated from 3.24104.14 to 3.24111.9 in the details of versions history.
 
I have no idea why the same code acts differently in ICON and BUTTON.
The problem is on my code? Or version update?
Any suggestion to resolve? Or debug?
Thank you in advance.
 
Best regards
James
 
 
Categories:
  • WarrenBelz Profile Picture
    156,921 Most Valuable Professional on at
    Put the Form in a Container and PDF the Container and see if that works.
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

     
  • James-FA254 Profile Picture
    27 on at
    Hi @WarrenBelz, 
     
    Both Submit button and PDF icon are already in different container.
     
     
    Thanks anyway.
    James
     
  • WarrenBelz Profile Picture
    156,921 Most Valuable Professional on at
    Yes - but you need to PDF the Container, not the Form.
  • James-FA254 Profile Picture
    27 on at
    Implement "MainContainer1" instead of "EditForm", right?
    Hm.... Still corrupt.
     
  • Verified answer
    WarrenBelz Profile Picture
    156,921 Most Valuable Professional on at
    Containers should PDF, even if the output is not formatted properly - however the PDF function is still experimental and really should not be used in Production Apps - you may have found another (of many) bugs presently in it.
  • James-FA254 Profile Picture
    27 on at
    Hi WarrenBelz,
     
    Thank you for rectify my mistake.
    And remind me the PDF function is still experimental (though it is sad >_<).
     
    Best regards
    James

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard