arichika / RotativaCore

for ASP.NET Core on Azure Web Apps (by Windows). Support .NETStandard 2.0
https://www.nuget.org/packages/RotativaCore/
MIT License
14 stars 6 forks source link

Error generating PDF #11

Open luvssti opened 4 years ago

luvssti commented 4 years ago

Hi, I just want to if how can I fix this error?

Thank You and God Bless!

`public class PDFModel : PageModel {

    public ActionResult OnGet()
    {
        var report = new ActionAsPdf(Url.Content("~/TestPDF"), new { })
        {
            PageMargins = { Left = 10, Bottom = 10, Right = 10, Top = 10 },
            PageSize = RotativaCore.Options.Size.Legal,
            CustomSwitches = "--disable-smart-shrinking"

        };
        return report;
    }

}`

Win32Exception: The system cannot find the file specified. System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) System.Diagnostics.Process.Start() RotativaCore.WkhtmlDriver.Convert(string wkhtmlPath, string switches, string html, string wkhtmlExe) RotativaCore.WkhtmltopdfDriver.Convert(string wkhtmltopdfPath, string switches) RotativaCore.AsPdfResultBase.WkhtmlConvert(string switches) RotativaCore.AsResultBase.CallTheDriver(ActionContext context) RotativaCore.AsResultBase.BuildFile(ActionContext context) RotativaCore.AsResultBase.ExecuteResult(ActionContext context) Microsoft.AspNetCore.Mvc.ActionResult.ExecuteResultAsync(ActionContext context) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultAsync(IActionResult result) Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeResultAsync(IActionResult result) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResultFilterAsync<TFilter, TFilterAsync>() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) Microsoft.AspNetCore.Routing.EndpointMiddleware.gAwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

arichika commented 4 years ago

The error,

Win32Exception: The system cannot find the file specified.
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
System.Diagnostics.Process.Start()

indicate missing wkhtmltopdf.exe in your project / bin directory.

e.g. https://github.com/arichika/RotativaCore/tree/master/src/RotativaCore.SampleWebApp.3.0

Please check this.

  1. Put Binares ( wkhtmltoimage.exe , wkhtmltopdf.exe ) into the directory (project)\WkHtmlToPdf
  2. Specify that those files be copied at build time. https://github.com/arichika/RotativaCore/blob/master/src/RotativaCore.SampleWebApp.3.0/RotativaCore.SampleWebApp.3.0.csproj#L25
DealerCorp commented 4 years ago

implement RazorPageAsPdf https://stackoverflow.com/questions/59349176/razor-pages-pdf-generation-with-rotativa-model-null

arichika commented 4 years ago

Ohh... That's great solution. The issue was that you wanted to run it in Razor Pages. I was mistaken. When I see the work I'm working on, I'll try to implement it in this module.

luvssti commented 4 years ago

Thank You for the reply... I've been busy on another project and just got back to continue my previous project.

tawani commented 2 years ago

What is the point of this project? Can you run an executable in Azure bin folder?