"application/octet-stream", "DemoPdf.pdf") Var pdfFile = _converter.Convert(htmlToPdfDocument) HtmlToPdfDocument htmlToPdfDocument = new HtmlToPdfDocument() ObjectSettings.WebSettings = webSettings ObjectSettings.FooterSettings = footerSettings ObjectSettings.HeaderSettings = headerSettings HeaderSettings.Right = "Page of " įooterSettings footerSettings = new FooterSettings() įooterSettings.Center = "This is for demonstration purposes only." HeaderSettings headerSettings = new HeaderSettings() WebSettings webSettings = new WebSettings() ![]() ObjectSettings objectSettings = new ObjectSettings() GlobalSettings.Margins = new MarginSettings GlobalSettings.Orientation = Orientation.Portrait GlobalSettings.ColorMode = ColorMode.Color GlobalSettings globalSettings = new GlobalSettings() Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. I have created a method in the controller to generate PDF files. Download these libraries into your project folder.Īfter clicking on libraries you will find the option to download the file. We have some compulsory libraries to generate PDFs in our project. Using DinkToPdf.Contracts Download the libraries: New SynchronizedConverter(new PdfTools())) Īnd do not forget to add these libraries in your program.cs. Add services to the container.ī(typeof(IConverter), Install-Package DinkToPdf Configure the Package into Program.cs:Īfter installing the package we have to configure the DinkToPdf service into Program.cs file so we can use it in our project. We can install this package by “Package Manager Console”. ![]() Install-Package DinkToPdf:ĭinkToPdf is an open-source library that we can use as a package to build pdf documents in our ASP.NET Core web API project. Now we have successfully created our project. Give a name to the project and select a location to save the project, click on next and select a. Configure Project:Ĭonfigure the project setting after project template selection. After that select “ASP.NET Core Web API” as a project template. To create a new project first open visual studio and click on “create a new project”. ![]()
0 Comments
Leave a Reply. |