carloscds / HtmlToPDFCore

Convert HTML to PDF
MIT License
51 stars 25 forks source link

"error":"Permission denied" #6

Closed pietschmax closed 2 years ago

pietschmax commented 2 years ago

First of all thanks for your Package! I hosted your package on a debian Server + REST API, when i call my PDF Function the request is always "error":"Permission denied". I forget some settings?

[HttpGet] [Route("identificationPdf/{shippingId}")] public IActionResult IdentificationPdf(int shippingId) { var shipping = _shippingService.GetById(shippingId);

        HtmlToPdf pdf = new HtmlToPdf();
        string markSheet = string.Empty;
        markSheet = System.IO.File.ReadAllText("Helper/IdentificationPdf.html");
        markSheet = markSheet.Replace("ShippingGoods", shipping.ShippingGoods)
          .Replace("IdentificationNumber", shipping.IdentificationNumber)
          .ToString();
        var htmlToPdf = new HtmlToPDFCore.HtmlToPDF();
        var bytes = htmlToPdf.ReturnPDF(markSheet);
        return File(bytes, "application/pdf", "Versandgut/Versand#"+ shipping.Id + ".pdf");
    }

    private byte[] ReturnPDF(string html)
    {
        var dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
        dir = Path.Combine(dir, "rotativa");
        Wkhtmltopdf.NetCore.RotativaConfiguration.RotativaPath = dir;
        Wkhtmltopdf.NetCore.RotativaConfiguration.IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
        var pdf = new Wkhtmltopdf.NetCore.HtmlAsPdf();
        var buffer = pdf.GetPDF(html);
        return buffer;
    }

thats everything what I implemented.

Probably you have a idea. BR Max :)

pietschmax commented 2 years ago

On my local System works everything. I think the Issue have something to do with the Debian Server.

carloscds commented 2 years ago

@SchmutzmeisterNo1 Are you caling rotativa direct ?

pietschmax commented 2 years ago

I fixed the problem with chmod x- for the rotativa explorer. Thank you :)