Docker has become standard for millions of people in the software industry to build and develop software in packages called containers. Containers are isolated from each other and contain all the necessary packages, library files, configuration files. It separates the application from the infrastructure as everything required to run the application is bundled into it.
You can use Aspose.Cells in containers to process spreadsheets. In this article, we will demonstrate the Excel to PDF conversion and guide you to create your own container having all the necessary components to run this application.
It is assumed that you have installed docker on your computer and then pulled the microsoft/dotnet container as follows:
docker pull microsoft/dotnet
Once you have pulled it, run the container and execute the following commands in the terminal.
apt update && apt upgrade
apt install wget
apt-get install sudo
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update; \ sudo apt-get install -y apt-transport-https && \ sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-3.1
sudo apt-get install libgdiplus ln -s libgdiplus.so gdiplus.dll
sudo apt-get install libc6-devStep 1: apt update && apt upgrade
Once you have installed all the necessary libraries, you can develop your simple .NET Core based console application in Visual Studio 2019 to convert Excel to PDF and save it on your host computer containing the container configured above.
As we are demonstrating the Excel to PDF conversion, your console application may look like as follows:
// Instantiate new workbook Workbook workbook = new Workbook("sample.xlsx"); // Define PdfSaveOptions PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); // Set the compliance type pdfSaveOptions.Compliance = PdfCompliance.PdfA1b; // Save the file workbook.Save("output.pdf", pdfSaveOptions);
Once this application is compiled, now we will link our host system folder with the folder in the container before running the container as follows:
docker run -it -v ~/Desktop:/Desktop Microsoft/dotnet /bin/bash
We have linked our desktop folder with a folder named desktop in the container and now we can navigate to our compiled application folder having .proj file.
Run the following command and you will get the application executed.
After running this command you will get PDF in the same folder.
Source Excel File:
For more information on Excel to PDF conversion, have a look at the following article:
Excel To PDF Conversion