Upload Text Document and convert it to PDF. Upload text Document pdf
Today, I learned some PDF-related knowledge in the ASP. NET MVC environment. The idea is to convert a file into a PDF file when the file is uploaded successfully.
Open your project, run the NuGet Package Manager, and download an item named iTextSharp:
Click "Install". The system prompts you to confirm the installation. If the installation is successful or the project has been installed, the status is shown as follows:
Create an Action on the controller ):
In the controller, another operation method is to process file upload and Convert PDF:
FileStream class to open the file and read, get the byte [] array of the document. ITextSharp Class Object mongowriter, go to the GetInstance instance, and finally pass the array byte [] of the document to the paragrahp () method of the iTextSharp object.
After the operation is created based on the controller, we can create the view UploadConvertPDF (). This exercise uses Razor to upload files:
Demo: