Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Unable to find the Error in code of pdf creating function

(0) ShareShare
ReportReport
Posted on by

I am trying to use the following function to create pdf of the data of my gallery from my screen:

 

Office365Outlook.SendEmailV2(user().Email,"My First expo pdf from powerapp","power app report",{Attachments:Table({Name:"SearchRepo1.pdf",ContentBytes:PDF(Gallery4)})})

 

Please check and advise the correction required.

 

MIA27_1-1679163611510.png

 

Note : I have properly followed the connector process and connected the outlook account.

 

 

  • MIA27 Profile Picture
    on at
    Re: Unable to find the Error in code of pdf creating function

    As you showed, container and orientation should be together, so it should as below

     

    ContentBytes: PDF(Gallery4 , {Expandcontainer:true},{ Orientation : Landscape,Size:Papersize.A1,Margin:"24pt 24pt 24pt 24pt"})

     

    Please guide I am ok with the syntax or orientation should be before expand.

     

    Also, can you guide me how to know the current export size of pdf, this will help me to make adjustment

     

     

  • Community Power Platform Member Profile Picture
    on at
    Re: Unable to find the Error in code of pdf creating function

    Hi @MIA27 ,

     

    About orientation used after galley

    PDF(Galleydata,{ Orientation : Landscape,Size:Papersize.A1,Margin:"24pt 24pt 24pt 24pt"})

     

    Thanks,

     

  • MIA27 Profile Picture
    on at
    Re: Unable to find the Error in code of pdf creating function

    Dear Chitrakant 

    Thank you for your time and advise,

     

    Expand container I already used after posting the question, earlier only screen was getting exported.

    And about orientation syntax where to be used?. after which line,  any web link where it is explained.

     

    Also, how to know the current exported pdf -  was of what size. any default of the code is there.

    I tried to find the exported page size from my acrobat reader but could not.

    This will give me an in declaration of orientation.

     

    regards

     

     

  • Community Power Platform Member Profile Picture
    on at
    Re: Unable to find the Error in code of pdf creating function

    HI @MIA27 ,

     

    Use expandcontaine after gallery

    Office365Outlook.SendEmailV2(
    User().Email,
    "Subject to be here PowerApp of serial " & FindSerialNo.Text,
    "Email to be here of powerapp",
    {
    Attachments: Table(
    {
    Name: "ServiceDataRepo.pdf",
    ContentBytes: PDF(Gallery4 , {Expandcontainer:true})
    }
    )
    }
    )

     

     

    For kind your info -

    PDF also have { Orientation : Landscape,Size:Papersize.A1,Margin "24pt 24pt 24pt"}

     

    Thanks,

  • MIA27 Profile Picture
    on at
    Re: Unable to find the Error in code of pdf creating function

    Got stuck in paper size of the pdf. if it is more than one page the last line etc gets cut.

    How to adjust this in A4 size, so what ever fits it will be there, rest to be in next page.

    I saw some code in Reza video, but how to bring to my code . 

    Please guide the add line in the below code to fix this issue :

     

    Office365Outlook.SendEmailV2(
    User().Email,
    "Subject to be here PowerApp of serial " & FindSerialNo.Text,
    "Email to be here of powerapp",
    {
    Attachments: Table(
    {
    Name: "ServiceDataRepo.pdf",
    ContentBytes: PDF(Gallery4)
    }
    )
    }
    )

     

    Image of the page is as below

    MIA27_0-1679247207148.png

     

    Pls note above that the first page portion cut and came in next page top , same happening with every page

     

  • Verified answer
    Community Power Platform Member Profile Picture
    on at
    Re: Unable to find the Error in code of pdf creating function

    Hi @MIA27 ,

     

    Yes, It is works.

     

    Thanks,

  • MIA27 Profile Picture
    on at
    Re: Unable to find the Error in code of pdf creating function

    I also wanted to confirm you about the below:

    The app is under development and my email id in outlook connector which is connected. It started working fine, it is exporting with attachment.

     

    Later the app will be given to another user's who also are in the same environment of sharepoint and outlook with different email id.

    So the pdf creation button will work for them from their mobile ?. No issue ?. 

     

    please guide. 

  • MIA27 Profile Picture
    on at
    Re: Unable to find the Error in code of pdf creating function

    Thank you it worked, 

    But very strange when written in single line its a problem. The same written by you in coding which I copied and pasted it worked. Which means I am unable to track the space, but i checked several times.

    For my learning, you people write the code directly or use another app for writing. 

     

    Regards

     

  • Verified answer
    Community Power Platform Member Profile Picture
    on at
    Re: Unable to find the Error in code of pdf creating function

    Hi @MIA27 ,

     

    This is my test code -

     

    Office365Outlook.SendEmailV2(
    User().Email,
    "PDF File",
    "Galley file",
    {
    Attachments: Table(
    {
    Name: "Galleryfile.pdf",
    ContentBytes: PDF(Gallery2_3)
    }
    )
    }
    )

  • MIA27 Profile Picture
    on at
    Re: Unable to find the Error in code of pdf creating function

    sorry, tried same result.

    deleted and reconnected but still same error.

     

    can you please paste your test code

    so that i can cross check

     

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,537 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,908 Most Valuable Professional

Leaderboard