Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to return web response in MVC #6

Open
surya5353 opened this issue Sep 3, 2018 · 1 comment
Open

How to return web response in MVC #6

surya5353 opened this issue Sep 3, 2018 · 1 comment

Comments

@surya5353
Copy link

Dear all,

Unable to return web response in MVC5. Here is my code.

`public ActionResult DownloadPdfDetailedAnalysis()
{

        Report report = new Report(new PdfFormatter());
        FontDef fd = new FontDef(report, "Helvetica");
        FontProp fp = new FontPropMM(fd, 25);
        Page page = new Page(report);
        page.AddCenteredMM(80, new RepString(fp, "Hello World!"));
        return RT.ViewPDF(report, "HelloWorld.pdf")

}`

i want to return as pdf and open in new tab

@DagerD
Copy link

DagerD commented May 27, 2021

Hello, @surya5353 !

I Found out a working example for your question.
First, I had to wrote my own "Creator" method
image

And my controller looks like following:

    public ActionResult First()
    {
        var test = PDFWorker.CreatePDF();
        test.Save("F:/RiderProjects/rzn/ConfDataRZN/dxf/test.pdf");
        Response.Clear();
        Response.ContentType = "application/pdf";
        
        if (test.page_Cur == null) {
            test.CreatePDF();
        }

        test.formatter.Create(test, Response.OutputStream);
        Response.End();

        return null;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants