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

SaveOnServerPath not work #66

Open
zanyar3 opened this issue Jun 13, 2020 · 1 comment
Open

SaveOnServerPath not work #66

zanyar3 opened this issue Jun 13, 2020 · 1 comment

Comments

@zanyar3
Copy link

zanyar3 commented Jun 13, 2020

ViewAsPdf use to Save file on Server Path but not work by SaveOnServerPath Property

var pdfname = String.Format("{0}.pdf", Guid.NewGuid().ToString());
var path = Path.Combine(@"MyPathProject\wwwroot\doc\Claim\Request", pdfname);
path = Path.GetFullPath(path);
var pdfResult = new ViewAsPdf
{
     ViewName = "_ToPDF",
     Model = memo,
     FileName = pdfname,
     SaveOnServerPath = path
};
@ArjanKw
Copy link

ArjanKw commented Aug 18, 2024

Late, but just for reference if anyone stumbles on this issue. This works:

var pdf = new ViewAsPdf()
{
    SaveOnServerPath = "wwwroot/output.pdf"
};

pdf.BuildFile(this.ControllerContext);

SaveOnServerPath is obsolete though. If you don't specify it, a byte array is returned, which you can use to save the file yourself:

var pdfFile = new ViewAsPdf().BuildFile(this.ControllerContext);
File.WriteAllBytes("wwwroot/output.pdf", pdfFile);

Added this as documentation in #92.

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