Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
270
Must I save a report each time?
posted

What I want to accomplish is simple. Generate a PDF from scratch and send it to the user through the web browser. I just don't understand why these powerful tools don't seem to lead to that end.

After finally figuring out how to create a report, I just want the user to get it and go. First, I don't even know if my report is going to render anything. I can't, due to policy on the job site, be expected to use the Report.Publish method because all documentation I see for it shows the Publish method will ONLY save a file.

I want the user to click a button on a webpage and then receive a prompt to open or save the PDF document that gets sent. I don't want to cache or queue temp documents because multiple people will be using the same site and temp caches get messy to manage.

I thought the Document Exporter control would offer me a solution, but that control expects an Ultra WebGrid as an export parameter. I'm not using grids. I want to put some text at certain spots on the page and images or charts at other parts of the page. I don't even know if my current code is generating a proper report with a section of text because I can't get it to export. Here's the code I'm using to create a report:

        Dim scoreCard As Report = New Report

        Dim sectionScoreCard As Section.ISection = scoreCard.AddSection

        Dim textBP1 As QuickText.IQuickText = sectionScoreCard.AddQuickText("I expect to see this text on a PDF page")
        textBP1.Alignment.Horizontal = Alignment.Left
        textBP1.Margins.Left = 40
        textBP1.Margins.Right = 40
        textBP1.Margins.Top = 40
        textBP1.Margins.Bottom = 300

Am I at least on the right track? Some people on this forum say they can get reports from this control, or say it's easy. Can anybody just post a sample section of code that worked for them?

I'm using ASP.NET not Windows Forms

  • 2848
    Verified Answer
    posted

    Hi,

    Try doing:

        Context.Response.ContentType = "application/pdf"
        Report.Publish(Context.Response.OutputStream, Infragistics.Documents.Report.FileFormat.PDF)

    Regards,

    Andres