title: DinkToPdf poorly generating pdf on .Net Core while trying to render view from Controller
body: <p>I am trying to render view from controller and then convert it to PDF. 
  I get the result, but its 1474 empty pages and one(last) page has the small version of generated view . 
  <a href="https://i.stack.imgur.com/4CkcB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4CkcB.png" alt="enter image description here"></a></p>
  
  <p>ControllerExtension.cs</p>
  
  <pre><code> public static class ControllerExtensions
  {
      public static async Task&lt;string&gt; RenderViewAsync&lt;TModel&gt;(this Controller controller, string viewName, TModel model, bool partial = false)
      {
          if (string.IsNullOrEmpty(viewName))
          {
              viewName = controller.ControllerContext.ActionDescriptor.ActionName;
          }
  
          controller.ViewData.Model = model;
  
          using (var writer = new StringWriter())
          {
              IViewEngine viewEngine = controller.HttpContext.RequestServices.GetService(typeof(ICompositeViewEngine)) as ICompositeViewEngine;
              ViewEngineResult viewResult = viewEngine.FindView(controller.ControllerContext, viewName, !partial);
  
              if (viewResult.Success == false)
              {
                  return $"A view with the name {viewName} could not be found";
              }
  
              ViewContext viewContext = new ViewContext(
                  controller.ControllerContext,
                  viewResult.View,
                  controller.ViewData,
                  controller.TempData,
                  writer,
                  new HtmlHelperOptions()
              );
  
              await viewResult.View.RenderAsync(viewContext);
  
              return writer.GetStringBuilder().ToString();
          }
      }
  }
  </code></pre>
  
  <p>SettingsController.cs</p>
  
  <pre><code>[HttpGet]
      [Route ("/settings/a")]
      public async Task&lt;IActionResult&gt; GenerateAcceptanceActPdf (int id, List&lt;AcceptanceAct&gt; model) {
          var data = Repository.GetAcceptanceActByUserId (id);
  
          var viewHtml = await this.RenderViewAsync ("AcceptanceAct", model);
  
          var globalSettings = new GlobalSettings {
              ColorMode = ColorMode.Color,
              Orientation = Orientation.Portrait,
              PaperSize = PaperKind.A4,
              Margins = new MarginSettings { Top = 10 },
              DocumentTitle = "PDF Report",
              //Out = @"D:\PDFCreator\Employee_Report.pdf"
          };
  
          var output = _converter.Convert (new HtmlToPdfDocument () {
              GlobalSettings=globalSettings,
  
              Objects = {
                  new ObjectSettings () {
                      HtmlContent = viewHtml,
                          PagesCount = true,
                          WebSettings = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine (Directory.GetCurrentDirectory (), "assets", "styles.css") }
  
                  },
  
              }
          });
          return File (output, "application/pdf");
      }
  </code></pre>
  
  <p>AcceptanceAct.cshtml</p>
  
  <pre><code>@model List&lt;AcceptanceAct&gt; 
  &lt;p&gt;some text here&lt;/p&gt;
  </code></pre>
  
  <p>NOTE: In the picture below, generated view on the last page is Layout and AcceptanceAct.cshtml combined. </p>
  
  <p>How can I stretch it on full page and why are there 1475 pages instead of 1?</p>