Emailing FlexReports

Posted by: eamon9999 on 4 October 2017, 12:52 pm EST

    • Post Options:
    • Link

    Posted 4 October 2017, 12:52 pm EST

    I’m unable to find any example code for producing reports without using the report viewer.

    What I want to be able to do is to create a batch of pdf reports and email them to people, so that everyone gets their own report. So there should be a button that’s clicked and then the reports are generated on the server and emailed to a list of employees.

    If you could point me in the right direction I’d much appreciate it. VB.net would be fantastic…(But not the end of the world if it’s c#)

  • Posted 5 October 2017, 5:25 am EST

    Hi Eamon,

    For this, you need to use WebApi Report Export Service. Please use the following code snippet for Exporting Report to PDF on the server.

    Public Sub generateReport(url As [String])
    
        Dim req As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
    
        Dim res As HttpWebResponse = DirectCast(req.GetResponse(), HttpWebResponse)
    
        If res.StatusCode.ToString() = "OK" Then
            Dim path = "C:\Users\Admin\Downloads\Report.pdf"
    		Using stream = System.IO.File.Create(path)
    
                res.GetResponseStream().CopyTo(stream)
    
    
            End Using
    
        End If
    
        res.Close()
    End Sub
    

    Where url=“http://demos.componentone.com/ASPNET/c1webapi/4.0.20172.105/api/report/ReportsRoot/FlexCommonTasks/FlexCommonTasks.flxr/MultiValue DataBound Parameters/$report/export?exportOptions.format=pdf&exportFileName=MultiValue DataBound Parameters&parameters.pCategory=1”

    Please refer to the documentation for Configuring FlexReports WebAPI[1] and export Report[2] and Demo sample[3]

    Thanks,

    Manish Kumar Gupta

    [1]http://helpcentral.componentone.com/nethelp/c1webapi/Working%20with%20Reports.html

    [2]http://helpcentral.componentone.com/nethelp/c1webapi/Export.html

    [3]http://demos.componentone.com/ASPNET/WebApiExplorer

  • Posted 16 October 2017, 11:27 am EST

    Thanks for that.

    I can’t seem to get my report path correct. I keep getting - The remote server returned an error: (404) Not Found.

    If my report path is

    ~\Content\ReportsRoot\rptMyReport.flxr

    What should I be putting in the URL? - I’ve tried lots of different combinations.

    One other query - what happens if you take down the WebApi Report Export Service ? It seems that my project will now be reliant on this always being available.

    Is there another way of doing this, where I’m not relying on your report export service?

  • Posted 18 October 2017, 5:15 am EST

    think you are trying to use our publicly hosted reporting services, I would not recommend you use that in production as they are for demo purposes only.

    Also the report file ( .flxr) should be available on the Web Service so that it could be exported, as is the case with our Demo where FlexCommonTasks.flx is available on the same server where the export service is called.

    I would suggest you to host your own webservice and then use it to export the Report

    Please go through the configuration page of our Documentation to know how to add Report to Web Api

    http://helpcentral.componentone.com/nethelp/c1webapi/Working%20with%20Reports.html

  • Posted 27 July 2018, 12:11 pm EST

    Please could you tell me how to password protect the report?

    I’ve tried a few things like: exportOptions.OwnerPassword but none of them seem to work.

    I also have no idea how to get a list of Export Options. I can’t find that anywhere on your website.

    Thanks,

    Eamon

  • Posted 6 August 2018, 3:04 am EST

    Hi,

    We are extremely sorry for the delayed response.

    Please use userPassword for protecting your exported PDF.

    Format:

    api/report/{folder path}/{report name}/$report/export?exportOptions.format=pdf&exportFileName={file_name}&exportOptions.userPassword={password}
    

    Example Link:

    https://demos.componentone.com/ASPNET/c1webapi/4.0.20182.136/api/report/ReportsRoot/FlexCommonTasks/FlexCommonTasks.flxr/Simple%20List/$report/export?exportOptions.format=pdf&exportFileName=Simple%20List&exportOptions.userPassword=hello2

    ~Manish

  • Posted 1 February 2022, 12:44 pm EST

    Sometimes the password does not work, or the user can put in an incorrect password.

    For example, the user specifies this password:

    Kilk#143

    But the document can not be opened with that password.

    Kilk

    appears to open the document.

    Is there a solution for this problem?

  • Posted 2 February 2022, 3:03 am EST

    Hi Eamon,

    Thank you for reporting the issue. We are able to replicate the issue at our end and it has been forwarded to the concerned team for further investigation with the internal tracking id: C1Web-28911

    We will let you know as we get an update on this.

    In the meantime, please set the password without any symbols. Please use only the Alphabet and Digits.

    Regards,

    Manish Gupta

  • Posted 24 October 2024, 9:29 am EST

    Sorry for the late reply to this query.

    We have discovered that when applying a password, it does not work when people open the pdf with Apple products, such as iphones. The password is ‘stripped out’.

    It works fine for Windows.

    Is this a known issue?

  • Posted 25 October 2024, 8:12 am EST

    Hi Eamon,

    We tried exporting a PDF report with password and opening it on Windows, Macbook and iPhone. However, the report seems to load as expected.

    Please Note: Make sure your password does not contain spaces as spaces are not allowed in passwords.

    Thanks,

    Anand

  • Posted 25 October 2024, 8:57 am EST

    Hi Anand,

    Thank you for attempting to recreate this.

    I do not believe it is a problem with the password. It is a very simple password with just letters. The password is applied when I try to open the pdf in Windows, but Apple products ignore the password.

    Could it be a problem with the version of the C1 reports I am using, which is 4.0.20172.105

    Maybe this issue has been resolved for the version you tried it with

  • Posted 28 October 2024, 6:22 am EST

    Hi Eamon,

    Yes, it is possible that the issue may be specific to your version of C1Reports as v4.0.2017x.xxx was released back in 2017. We’ll suggest upgrading it to the latest version of C1Reports.

    You can also try exporting a sample report from our Demo Web API and testing on the apple devices on your end, you may refer to Web API. or use: https://developer.mescius.com/componentone/demos/aspnet/5/C1WebAPI/latest/api/report/ReportsRoot/FlexCommonTasks/FlexCommonTasks.flxr/Simple%20List/$report/export?exportOptions.format=pdf&exportFileName=Simple%20List&exportOptions.userPassword=test

    Regards,

    Anand

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels