diff --git a/Document-Processing-toc.html b/Document-Processing-toc.html index 9b8a46c833..11f9ef10c9 100644 --- a/Document-Processing-toc.html +++ b/Document-Processing-toc.html @@ -281,7 +281,7 @@
  • - Working with OCR + OCR Processor Features
  • Troubleshooting @@ -2954,6 +2954,9 @@
  • Mac
  • +
  • + Docker +
  • Console
  • diff --git a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-Docker.md b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-Docker.md new file mode 100644 index 0000000000..9d1d00ad01 --- /dev/null +++ b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-Docker.md @@ -0,0 +1,118 @@ +--- +title: Create PDF Files in a Docker Environment | Syncfusion +description: Learn how to create PDF files in a Docker environment using Syncfusion and a containerized .NET application. +platform: document-processing +control: PDF +documentation: UG +keywords: docker getting started, docker sample project, container basics, docker tutorial, docker setup, run docker app, docker beginner guide +--- + +# Create PDF Files in a Docker Environment + +The Syncfusion® [.NET PDF library](https://www.syncfusion.com/document-sdk/net-pdf-library) is a powerful and versatile solution for creating, reading, and editing PDF documents in .NET applications. It also provides advanced features such as merging and splitting PDFs, adding stamps, working with form fields, and securing PDF files with encryption and permissions. + +To integrate the .NET PDF library into your Docker application, refer to the official documentation sections on [NuGet Package Required](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/nuget-packages-required) or [Assemblies Required](https://help.syncfusion.com/document-processing/pdf/pdf-library/net/assemblies-required) for step-by-step guidance. + +## Steps to Create PDF Files in a Docker Container + +Step 1: Create a new ASP.NET Core MVC application. +![Create ASP.NET MVC Web application in Visual Studio](GettingStarted_images/Docker-Image1.png) + +Step 2: In the project configuration window, name your project and select Next. +![Configuration Window](GettingStarted_images/Docker-Image2.png) + +Step 3: Enable the Docker support with Linux as a target OS. +![Docker Support Window](GettingStarted_images/Docker-Image3.png) + +Step 4: Install the [Syncfusion.Pdf.Net.Core](https://www.nuget.org/packages/Syncfusion.Pdf.Net.Core) NuGet package as a reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org/). +![NuGet Package](GettingStarted_images/Docker-Image4.png) + +N> Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, you also have to add "Syncfusion.Licensing" assembly reference and include a license key in your projects. Please refer to this [link](https://help.syncfusion.com/common/essential-studio/licensing/overview) to know about registering Syncfusion® license key in your application to use our components. + +Step 5: A default action method named Index will be present in `HomeController.cs`. Right-click on this Index method and select Go To View where you will be directed to its associated view page `Index.cshtml`. Add a new button in the `Index.cshtml` as follows. + +{% tabs %} +{% highlight HTML %} + +@{Html.BeginForm("CreatePDFDocument", "Home", FormMethod.Get); + { +
    + +
    + } + Html.EndForm(); +} + +{% endhighlight %} +{% endtabs %} + +Step 6: The [PdfDocument](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.PdfDocument.html) object represents an entire PDF document that is being created. The [PdfTextElement](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Graphics.PdfTextElement.html) is used to add text in a PDF document and which provides the layout result of the added text by using the location of the next element that decides to prevent content overlapping. The [PdfGrid](https://help.syncfusion.com/cr/document-processing/Syncfusion.Pdf.Grid.PdfGrid.html) allows you to create table by entering data manually or from an external data sources. + +Add the following code sample in ``ExportService`` class which illustrates how to create a simple PDF document using ``PdfTextElement`` and ``PdfGrid``. + +{% tabs %} +{% highlight c# tabtitle="C#" %} + + // Create a new PDF document. + using (PdfDocument pdfDocument = new PdfDocument()) + { + int paragraphAfterSpacing = 8; + int cellMargin = 8; + + // Add page to the PDF document. + PdfPage page = pdfDocument.Pages.Add(); + // Create title and description. + PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 16); + PdfTextElement title = new PdfTextElement("Weather Forecast", font, PdfBrushes.Black); + PdfLayoutResult result = title.Draw(page, new PointF(0, 0)); + + PdfStandardFont contentFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 12); + PdfTextElement content = new PdfTextElement( + "This component demonstrates fetching data from a service and exporting the data to a PDF document using Syncfusion .NET PDF library.", + contentFont, + PdfBrushes.Black); + PdfLayoutFormat format = new PdfLayoutFormat + { + Layout = PdfLayoutType.Paginate + }; + result = content.Draw( + page, + new RectangleF(0, result.Bounds.Bottom + paragraphAfterSpacing, page.GetClientSize().Width, page.GetClientSize().Height), + format); + // Create and style the PDF grid. + PdfGrid pdfGrid = new PdfGrid(); + pdfGrid.Style.CellPadding.Left = cellMargin; + pdfGrid.Style.CellPadding.Right = cellMargin; + pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent1); + // Assign data source. + pdfGrid.DataSource = forecasts; + pdfGrid.Style.Font = contentFont; + // Draw PDF grid into the PDF page. + pdfGrid.Draw(page, new PointF(0, result.Bounds.Bottom + paragraphAfterSpacing)); + using (MemoryStream stream = new MemoryStream()) + { + // Save the PDF document into the stream. + pdfDocument.Save(stream); + + return File(stream.ToArray(), "application/pdf", "Output.pdf"); + } + } + +{% endhighlight %} +{% endtabs %} + +Step 7: Build and run the sample in Docker. It will pull the Linux Docker image from the Docker hub and run the project. Now, the webpage will open in the browser. Click the button to convert the webpage to a PDF. + +You can download a complete working sample from GitHub. + +By executing the program, you will get a PDF document as follows. +![Docker Output](GettingStarted_images/Docker-Output.png) + +Click [here](https://www.syncfusion.com/document-processing/pdf-framework/net-core) to explore the rich set of Syncfusion® PDF library features. + +An online sample link to [create PDF document](https://document.syncfusion.com/demos/pdf/default#/tailwind) in ASP.NET Core. + + + + + diff --git a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-Web-API.md b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-Web-API.md index fb8bab0234..4b02e7d3fa 100644 --- a/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-Web-API.md +++ b/Document-Processing/PDF/PDF-Library/NET/Create-PDF-document-in-Web-API.md @@ -118,7 +118,7 @@ private MemoryStream ExportWeatherForecastToPdf() By executing the program, you will get the PDF document as follows. ![ASP.Net Core output PDF document](MVC_images/Output.png) -You can download a complete working sample from GitHub. +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/Getting%20Started/Web-API/Web-API-Project). Click [here](https://www.syncfusion.com/document-sdk/net-pdf-library) to explore the rich set of Syncfusion® PDF library features. diff --git a/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image1.png b/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image1.png new file mode 100644 index 0000000000..ccdd6c4a52 Binary files /dev/null and b/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image1.png differ diff --git a/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image2.png b/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image2.png new file mode 100644 index 0000000000..71f349c196 Binary files /dev/null and b/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image2.png differ diff --git a/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image3.png b/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image3.png new file mode 100644 index 0000000000..5d9ad72f0e Binary files /dev/null and b/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image3.png differ diff --git a/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image4.png b/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image4.png new file mode 100644 index 0000000000..1337d1e67e Binary files /dev/null and b/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Image4.png differ diff --git a/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Output.png b/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Output.png new file mode 100644 index 0000000000..0b0a07a5a0 Binary files /dev/null and b/Document-Processing/PDF/PDF-Library/NET/GettingStarted_images/Docker-Output.png differ