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 / PDF Function Print But...
Power Apps
Suggested Answer

PDF Function Print Button Not Formatting PDF Correctly

(1) ShareShare
ReportReport
Posted on by 24
Hi everyone,
 
Thanks in advance! I apologize if I did not provide enough information as I am new to Power Apps.
 
I created a Container2 in which it has my form with a Submit and Print button. I also created a PDFScreen_1 page that gives the preview of the PDF once I select "Print", however, it is not formatting it correctly. I am not sure if I am supposed to update the Height and Width (both are set to App.Width and App.Height) for the Container2 or PDFScreen_1. It's clear in the PDFScreen_1 preview it's not set appropriately. Could someone please guide me on how to correct this and let me know if additional information is needed? I would like margins and the form to fill the page neatly and professionally.
 
Thanks!
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,978 Moderator on at
     
    Can you please clarify more specific what we are looking at.
     
    I understand you are saying something isn't being viewed properly and I am guessing you mean those are pictures of your PDF control? But I am not sure
     
    Can you share pictures of your screen and container etc etc and walk us through the creation of what you are showing then can definitely help.
     
    Cheers! :-)
  • Power Platform 1919 Profile Picture
    2,205 Super User 2026 Season 1 on at
    Hi! Based on what you described, I’m making a few assumptions:
     
    It sounds like you’re using the experimental PDF() function in Power Apps to generate the PDF and then using a PDF Viewer control on PDFScreen_1 to show the preview.
     
    To fix the formatting, try this:
     
    In the PDF() function, you can pass options like "PageSize" (e.g., "A4", "A3") and set margins to control layout.
    You can refer to this Microsoft doc for details:
    👉 https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-pdf
     
     
    Also, your App.Width and App.Height might not match standard paper sizes. You may want to manually set the width/height to match.
     
    This YouTube video by Reza Dorrani explains it well:
    👉 https://youtu.be/PlBPCi4yXVs?feature=shared
     
    Hope this helps! Let me know if you’re using something different.
     
  • JH-02040138-0 Profile Picture
    24 on at
    @Michael E. Gernaey 

    Hi Michael, thanks for getting back to me!

     

    I created an app in which others will fill out a fillable form and submit it upon pressing the Submit button. I originally wanted the Submit button to also Print the form to PDF using the Media > PDFViewer experimental and could not figure out how to combine the 2 functions to work as one, so I created a Print button which upon pressing will Print to PDF. The two buttons are on my Main Screen and within the Main Screen I inserted my Container 2 that contains the fillable form linked to my data source. I have my Print button OnSelect set to:

    Set(

        varPDFmultiple,

        PDF(

            Container2, // actual name of my outer container

            {

                Orientation: PaperOrientation.Portrait,

                Size: PaperSize.A4,

                Margin: "0px",

                ExpandContainers: true,

                DPI: 300

            }

        )

    );

    Office365Outlook.SendEmailV2(

        "enter email address here",

        "Surface Emissions Monitoring Record PDF", //PDF name

        "Attached is the SEM Report.",

        {

            Attachments: Table({

                Name: "SEM_Report.pdf",

                ContentBytes: varPDFmultiple,

                '@odata.type': ""

            })

        }

    );

    Navigate(PDFScreen_1, ScreenTransition.None)

    and the Submit button OnSelect set to: SubmitForm(FinSEMfrm_1). I then created a second screen named PDFScreen_1 in which it contains my PdfViewer1 document and I set the Document to varPDFmultiple which displays how the PDF will look upon pressing (this was the image preview I attached). The goal is to have a multiple page PDF output with page breaks. The issue I see is when I inserted the PDF Viewer it had the document set to SamplePdf which the format looked great, but I changed it to varPDFmultiple (set in my formula in the Print button) in the PdfViewer1 of the PDFScreen_1 which caused the formatting to mess up and I cannot fix it. Please let me know if this makes sense. I appreciate your help!

  • Power Platform 1919 Profile Picture
    2,205 Super User 2026 Season 1 on at
    Hi @JH-02040138-0,
    can you try this code once, without DPI parameter?
    Set(
    
        varPDFmultiple,
    
        PDF(
    
            Container2, // actual name of my outer container
    
            {
    
                Orientation: PaperOrientation.Portrait,
    
                Size: PaperSize.A4,
    
                Margin: "0px",
    
                ExpandContainers: true
    
            }
    
        )
    
    );

    In my testing, I'm getting the PDF layout similar to the SamplePDF.
    Container_Image: 


    PDF_Image:


    Note: I just used a random form for demo purposes to show how the PDF renders.
    Let me know how it works for you!
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,978 Moderator on at
     
    Just to also add.
     
    So let's say you have a Form (like a real form) and you have your Submit Button.
     
    If you need code to run after (like your Print), you put it in the OnSuccess property of the Form itself. (not the button). The button would simply be telling the Form to do its thing (Submit), then the Form responds in either OnSuccess or OnFailure, so that you know if you should or shouldn't do the next step.
     
    In a button itself or other OnSelect, to do multiple actions separate them with a ; 
     
    Submit(Form1);
    Set(var1, "Test");
     
    As an example, but the Set would go in your OnSuccess or Onfailure not right under the Submit, to do the right structure, even though the button lets you do multiple things, if they are dependent on the Success/Failure of the Submit, then use those two properties ON the form.
     
    Hope that answers that part.
     
    If this helps please mark as such and maybe a like
  • Michael E. Gernaey Profile Picture
    53,978 Moderator on at
     
    Did Power Apps or my suggestions help? If you still need help let us know.
     
    Cheers
  • Power Platform 1919 Profile Picture
    2,205 Super User 2026 Season 1 on at
    Hi @JH-02040138-0, Just checking in to see if my previous answer hit the mark or if there’s anything else I can help you with.

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,055

#2
Valantis Profile Picture

Valantis 666

#2
11manish Profile Picture

11manish 666

Last 30 days Overall leaderboard