fpanaccia / Wkhtmltopdf.NetCore-deprecated

Rotativa + Net Core
The Unlicense
220 stars 94 forks source link

How to using in Project ClassLibrary #35

Closed jlfjunior closed 4 years ago

jlfjunior commented 4 years ago

I have a function in an project classlib, how can i using ?

fpanaccia commented 4 years ago

Hi, you should use the dependency injection...i dont know wha tis your use case, but in the constructor of your class you should add the interface IGeneratePdf, use it accordingly and then the project that use the library in should add in the the startup this line services.AddWkhtmltopdf();

jlfjunior commented 4 years ago

would like do do so.

    public byte[] MontaBytesPDF(bool convertLinhaDigitavelToImage = false, string urlImagemLogoBeneficiario = null)
    {
        #if NETSTANDARD2
                return (new Wkhtmltopdf.NetCore.HtmlAsPdf().GetPDF(MontaHtmlEmbedded(convertLinhaDigitavelToImage, true, 
                            urlImagemLogoBeneficiario)));
        #elif NETCOREAPP3
                return (new Wkhtmltopdf.NetCore.IGeneratePdf().GetPDF(MontaHtmlEmbedded(convertLinhaDigitavelToImage, 
                           true, urlImagemLogoBeneficiario)));
        #else
               throw new NotImplementedException();
        #endif
    }

Can you send an example using project Class Library ?