Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

[BUG] GetByteArrayViewInHtml(view, model) not working. #42

Open
SteveGrixti opened this issue Oct 8, 2020 · 0 comments
Open

[BUG] GetByteArrayViewInHtml(view, model) not working. #42

SteveGrixti opened this issue Oct 8, 2020 · 0 comments

Comments

@SteveGrixti
Copy link

Bug Information

Version Number of Plugin: 3.0.2
Version of VS: Microsoft Visual Studio 2019 V. 16.6.5
Target Framework: .NET Core 3.1

Steps to reproduce the Behavior

  1. Add services.AddWkhtmltopdf(); to startup.
  2. Add IGeneratePdf to constructor.
  3. Call GetByteArrayViewInHtml(view, model) and receive the respective value for the pdf generated.

Expected Behavior

Calling GetByteArrayViewInHtml(view, model) should return the pdf generate in a byte array format.

Actual Behavior

Calling GetByteArrayViewInHtml(view, model) instead throws the below exception:

Could not find an IRouter associated with the ActionContext. If your application is using endpoint routing then you can get a IUrlHelperFactory with dependency injection and use it to create a UrlHelper, or use Microsoft.AspNetCore.Routing.LinkGenerator.

Code snippet

This is the snippet in my controller:

var resPDF = await _pdfGenerator.GetByteArrayViewInHtml<ReportInEditViewModel>("PDFTemplates/Report", model);

This is a section of my view:

@model ViewModels.ReportInEditViewModel
@{  Layout = null; }

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="~/lib/fontawesome/css/all.min.css" />
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/lib/fontawesome/js/all.min.js"></script>
</head>
<body>
   ...
</body>
</html>

Final Comments

Any help would be greatly appreciated! 😉

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

No branches or pull requests

1 participant