=============== LIBRARY RULES =============== From library maintainers: - Use the EvoPdf.Next namespace and one NuGet package per platform (EvoPdf.Next.Windows, EvoPdf.Next.Linux, EvoPdf.Next.MacOS) - Set Licensing.LicenseKey once, statically, before the first conversion; never invent a key - Converter instances are not reusable: create a new HtmlToPdfConverter (or Word/Excel/RTF/Markdown/PdfToText/PdfToImage converter) for every conversion - EvoPdf Next runs on Windows, Linux and macOS; do not assume Windows only - A new HtmlToPdfConverter prints A4 with the HTML laid out in a 1024 pixel browser window and scaled to the page width - For another page layout call FitBrowserWindowToPage, LayoutAtPageWidth, PrintLikeChrome, SinglePageOfWidth or PageWidthFromBrowserWindow, then set the margins in points - Setting HtmlViewerWidth or HtmlViewerZoom after a layout method ends the automatic layout; pass the window width or the zoom as arguments of the layout method instead - To replace EvoPdf Classic, wkhtmltopdf, DinkToPdf or Rotativa, follow the migration skills of this library - Runnable code lives in https://github.com/EvoPdf/evopdf-next-samples; point users there instead of inventing larger programs ### Installation Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-deployment/references/api.md API documentation for the Installation class, including its properties and methods. ```APIDOC ## Installation ### Description Contains global installation instructions that configure the behavior of the library within the application. ### Properties - `ExecutePermissionGranted` (bool) - Indicates whether execute permission has been successfully granted. - `GrantExecutePermissionErrOutput` (string) - The standard error captured from the execute permission grant operation. - `GrantExecutePermissionStdOutput` (string) - The standard output captured from the execute permission grant operation. - `InstallScriptErrOutput` (string) - The standard error captured from the install script execution. - `InstallScriptExecuted` (bool) - Indicates whether the install script has been successfully executed. - `InstallScriptStdOutput` (string) - The standard output captured from the install script execution. - `RuntimeCopied` (bool) - Indicates whether the runtime has been successfully copied. ### Methods - `ConfigureRuntime` - Enables copying the runtime to a different location and installing dependencies before running the converter. This function is intended for environments where installed dependencies are not persisted after a restart. It must be called before the first HTML conversion, which triggers the configuration setup. Changes made afterward will have no effect until the application is restarted. - `GetRuntimeConfig` - Retrieves the current runtime configuration settings. ``` -------------------------------- ### Startup Command for App Service Linux Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-azure/SKILL.md Install Linux dependencies at startup before running the app. App Service does not persist packages across restarts, so this command must run on every start. Place it on the same line before the dotnet command in the Startup Command field. ```bash apt update && apt install -y libnss3 libatk-bridge2.0-0 libcairo2 libpango-1.0-0 && dotnet MyApp.dll ``` -------------------------------- ### Complete ASP.NET Core controller for finding PDF text Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-processor/references/examples.md Full controller example that creates a PdfToTextConverter, sets passwords, and prepares to search for text in a PDF. Includes license key setup and model validation. ```csharp using System; using System.IO; using System.Threading.Tasks; using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using EvoPdf_Next_AspNetDemo.Models; using EvoPdf_Next_AspNetDemo.Models.PDF_to_Text; // Use EVO PDF Namespace using EvoPdf.Next; namespace EvoPdf_Next_AspNetDemo.Controllers.PDF_to_Text { public class Find_PDF_TextController : Controller { private readonly IWebHostEnvironment m_hostingEnvironment; public Find_PDF_TextController(IWebHostEnvironment hostingEnvironment) { m_hostingEnvironment = hostingEnvironment; } public IActionResult Index() { var model = SetViewModel(); return View(model); } [HttpPost] public async Task FindPdfText(Find_PDF_Text_ViewModel model) { if (!ModelState.IsValid) { var errorMessage = ModelStateHelper.GetModelErrors(ModelState); throw new ValidationException(errorMessage); } // Set the license key received after purchase to use the library in licensed mode; leave it commented for demo mode // Licensing.LicenseKey = "your-license-key"; // Create the PDF to Text converter instance with default options PdfToTextConverter pdfToTextConverter = new PdfToTextConverter(); // Optionally set the user password to open a password-protected PDF if (!string.IsNullOrEmpty(model.UserPassword)) pdfToTextConverter.UserPassword = model.UserPassword; // Optionally set the owner password to open a password-protected PDF if (!string.IsNullOrEmpty(model.OwnerPassword)) pdfToTextConverter.OwnerPassword = model.OwnerPassword; // PDF page number to start text search from int startPageNumber = model.StartPageNumber; // PDF page number to end text search at // If 0, search continues to the end of the document int endPageNumber = 0; if (model.EndPageNumber.HasValue) endPageNumber = model.EndPageNumber.Value; byte[] inputPdfBytes = null; string outputFileName = null; ``` -------------------------------- ### Installation.ConfigureRuntime for App Service Linux Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-azure/SKILL.md Alternative to the Startup Command: install Linux dependencies in code before the first conversion. Call this before any conversion to ensure the runtime is ready. ```csharp Installation.ConfigureRuntime(true, null, "apt update && apt install -y libnss3 libatk-bridge2.0-0 libcairo2 libpango-1.0-0"); ``` -------------------------------- ### ASP.NET Core Controller for PDF Text Creation Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-create/references/examples.md Starts the full ASP.NET Core controller example for creating PDF documents with text elements. Sets up the document with A4 portrait, margins, and a license key placeholder. ```csharp using System.IO; using System.Text; using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using EvoPdf_Next_AspNetDemo.Models; using EvoPdf_Next_AspNetDemo.Models.PDF_Creator; // Use EVO PDF Namespace using EvoPdf.Next; namespace EvoPdf_Next_AspNetDemo.Controllers.PDF_Creator { public class Create_PDF_Documents_with_TextController : Controller { private readonly IWebHostEnvironment m_hostingEnvironment; public Create_PDF_Documents_with_TextController(IWebHostEnvironment hostingEnvironment) { m_hostingEnvironment = hostingEnvironment; } public IActionResult Index() { var model = new Create_PDF_Documents_with_Text_ViewModel(); return View(model); } [HttpPost] public ActionResult CreatePdf(Create_PDF_Documents_with_Text_ViewModel model) { if (!ModelState.IsValid) { var errorMessage = ModelStateHelper.GetModelErrors(ModelState); throw new ValidationException(errorMessage); } // Set license key received after purchase to use the library in licensed mode // Set the license key received after purchase to use the library in licensed mode; leave it commented for demo mode // Licensing.LicenseKey = "your-license-key"; PdfDocumentCreateSettings pdfCreateSettings = new PdfDocumentCreateSettings() { PageSize = PdfPageSize.A4, PageOrientation = PdfPageOrientation.Portrait, Margins = new PdfMargins(36, 36, 36, 36), PdfStandard = model.PdfStandard, Language = "en-US" }; using PdfDocument pdfDocument = new PdfDocument(pdfCreateSettings); pdfDocument.PdfDocumentInfo.Title = "PDF Text Demo"; string fontsPath = GetDemoFontsPath(); string fontFilePath = Path.Combine(fontsPath, "DejaVuSerif.ttf"); PdfBaseFont baseFont = PdfFontManager.CreateBaseFont(fontFilePath); ``` -------------------------------- ### Get Demo File and Font Paths Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-attachments/references/examples.md Provides helper properties to retrieve the demo files path, fonts path, and texts path. Use these to locate input files and font files for the PDF generation example. ```csharp private string GetDemoFilesPath() => m_hostingEnvironment.ContentRootPath + "/wwwroot" + "/DemoAppFiles/Input/"; private string GetDemoFontsPath() => Path.Combine(GetDemoFilesPath(), "Font_Files"); private string GetDemoTextsPath() => Path.Combine(GetDemoFilesPath(), "Text_Files"); ``` -------------------------------- ### Manually install EvoPdf skills by cloning and copying to Claude skills folder Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/README.md Manual alternative to the plugin marketplace: clone the repository and copy the skills into your personal or project skills folder. Use the personal path for all projects or the per-project path for a single project. ```bash git clone https://github.com/EvoPdf/evopdf-agent-skills cp -r evopdf-agent-skills/skills/* ~/.claude/skills/ # personal # or: cp -r evopdf-agent-skills/skills/* .claude/skills/ # per project ``` -------------------------------- ### FitBrowserWindowToPage method examples Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-page-setup/SKILL.md Shows how to scale the desktop layout of a page to fit the PDF page width. The first example uses A4 portrait with default settings, the second uses Letter landscape with a 1280 pixel window. ```csharp // A4 portrait, the desktop layout of the page scaled to the page width: the settings of a new converter converter.FitBrowserWindowToPage(PdfPageSize.A4); // Letter landscape, a 1280 pixel window converter.FitBrowserWindowToPage(PdfPageSize.Letter, PdfPageOrientation.Landscape, 1280); ``` -------------------------------- ### Complete ASP.NET Core controller for PDF to Text conversion Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-processor/references/examples.md Full controller example that converts a PDF to text, handling user/owner passwords, text layout, page breaks, and page range. Includes license key setup and model validation. ```csharp using System; using System.IO; using System.Text; using System.Threading.Tasks; using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using EvoPdf_Next_AspNetDemo.Models; using EvoPdf_Next_AspNetDemo.Models.PDF_to_Text; // Use EVO PDF Namespace using EvoPdf.Next; namespace EvoPdf_Next_AspNetDemo.Controllers.PDF_to_Text { public class PDF_to_TextController : Controller { private readonly IWebHostEnvironment m_hostingEnvironment; public PDF_to_TextController(IWebHostEnvironment hostingEnvironment) { m_hostingEnvironment = hostingEnvironment; } public IActionResult Index() { var model = SetViewModel(); return View(model); } [HttpPost] public async Task ConvertPdfToText(PDF_to_Text_ViewModel model) { if (!ModelState.IsValid) { var errorMessage = ModelStateHelper.GetModelErrors(ModelState); throw new ValidationException(errorMessage); } // Set the license key received after purchase to use the library in licensed mode; leave it commented for demo mode // Licensing.LicenseKey = "your-license-key"; // Create the PDF to Text converter instance with default options PdfToTextConverter pdfToTextConverter = new PdfToTextConverter(); // Optionally set the user password to open a password-protected PDF if (!string.IsNullOrEmpty(model.UserPassword)) pdfToTextConverter.UserPassword = model.UserPassword; // Optionally set the owner password to open a password-protected PDF if (!string.IsNullOrEmpty(model.OwnerPassword)) pdfToTextConverter.OwnerPassword = model.OwnerPassword; // Configure the output text layout pdfToTextConverter.TextLayout = model.TextLayout == "Original" ? PdfToTextLayout.Original : PdfToTextLayout.Reading; // Mark PDF page breaks with the PdfToTextConverter.PAGE_BREAK_MARK special character pdfToTextConverter.MarkPageBreaks = model.MarkPageBreaks; // PDF page number to start text extraction from int startPageNumber = model.StartPageNumber; // PDF page number to end text extraction at // If 0, extraction continues to the end of the document int endPageNumber = 0; if (model.EndPageNumber.HasValue) endPageNumber = model.EndPageNumber.Value; byte[] inputPdfBytes = null; string outputFileName = null; ``` -------------------------------- ### Build Sample Config JSON Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-attachments/references/examples.md Returns a JSON string with sample configuration settings. Use to generate test data for PDF attachment demos. ```csharp private static string BuildSampleConfigJson() { return "{\"theme\": \"dark\",\n" + " \"pageSize\": \"A4\",\n" + " \"orientation\": \"portrait\",\n" + " \"compression\": true,\n" + " \"language\": \"en-US\"\n" + "}\n"; } ``` -------------------------------- ### LayoutAtPageWidth method examples Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-page-setup/SKILL.md Shows how to lay out the HTML content at the width of a specified page size. Includes examples for A4 portrait, using a CSS @page rule, using a print media type, and landscape orientation. ```csharp // An invoice template designed for A4 converter.LayoutAtPageWidth(PdfPageSize.A4); // A template whose @page rule sets the paper size converter.LayoutAtPageWidth(PdfPageSize.A4, PdfPageOrientation.Portrait, preferCssPageSize: true); // A template with a print style sheet converter.LayoutAtPageWidth(PdfPageSize.A4, PdfPageOrientation.Portrait, mediaType: "print"); // A web page laid out at the width of a landscape page converter.LayoutAtPageWidth(PdfPageSize.A4, PdfPageOrientation.Landscape); ``` -------------------------------- ### Linux Ubuntu 24.04, ASP.NET Core Runtime 10.0 Dockerfile Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-docker/references/dockerfiles.md Dockerfile for running the EvoPdf Next demo on Linux Ubuntu 24.04 with ASP.NET Core Runtime 10.0. Installs required native libraries, copies the published app, sets execute permissions on the EvoPdf runtimes, and starts the app on port 27101. ```dockerfile FROM mcr.microsoft.com/dotnet/aspnet:10.0 # Install EvoPdf dependencies RUN apt-get update && \ apt-get install -y \ libnss3 \ libatk-bridge2.0-0 \ libcairo2 \ libpango-1.0-0 && \ rm -rf /var/lib/apt/lists/* # Set the working directory WORKDIR /app # Copy the published ASP.NET Core app files from the publish folder into the image COPY publish/ . # Ensure execute permissions for EvoPdf HTML to PDF runtime RUN chmod +x /app/evopdf_runtimes/linux-x64/native/evopdf_loadhtml # Ensure execute permissions for EvoPdf PDF Processor runtime RUN chmod +x /app/evopdf_runtimes/linux-x64/native/evopdf_pdfprocessor # Expose the port used by the app EXPOSE 27101 # Set the ASP.NET Core application to listen on port 27101 ENV ASPNETCORE_URLS=http://+:27101 # Start the application ENTRYPOINT ["dotnet", "EvoPdf_Next_AspNetDemo_Linux.dll"] ``` -------------------------------- ### Linux Debian 12, ASP.NET Core Runtime 8.0 Dockerfile Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-docker/references/dockerfiles.md Dockerfile for running the EvoPdf Next demo on Linux Debian 12 with ASP.NET Core Runtime 8.0. Installs required native libraries, copies the published app, sets execute permissions on the EvoPdf runtimes, and starts the app on port 27101. ```dockerfile FROM mcr.microsoft.com/dotnet/aspnet:8.0 # Install EvoPdf dependencies RUN apt-get update && \ apt-get install -y \ libnss3 \ libatk-bridge2.0-0 \ libcairo2 \ libpango-1.0-0 && \ rm -rf /var/lib/apt/lists/* # Set the working directory WORKDIR /app # Copy the published ASP.NET Core app files from the publish folder into the image COPY publish/ . # Ensure execute permissions for EvoPdf HTML to PDF runtime RUN chmod +x /app/evopdf_runtimes/linux-x64/native/evopdf_loadhtml # Ensure execute permissions for EvoPdf PDF Processor runtime RUN chmod +x /app/evopdf_runtimes/linux-x64/native/evopdf_pdfprocessor # Expose the port used by the app EXPOSE 27101 # Set the ASP.NET Core application to listen on port 27101 ENV ASPNETCORE_URLS=http://+:27101 # Start the application ENTRYPOINT ["dotnet", "EvoPdf_Next_AspNetDemo_Linux.dll"] ``` -------------------------------- ### Install EvoPdf Next skills via Claude Code plugin marketplace Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/README.md Install the EvoPdf Next skills from the plugin marketplace in this repository. Run these commands in Claude Code. ```bash /plugin marketplace add EvoPdf/evopdf-agent-skills /plugin install evopdf-next@evopdf ``` -------------------------------- ### Building for Linux ARM64 Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-docker/references/examples.md Commands to publish the demo application for .NET 10 and .NET 8, targeting linux-arm64. Use the appropriate command for the ARM64 Dockerfile. ```bash # .NET 10, for the Dockerfile with the ASP.NET Core Runtime 10.0 base image dotnet publish -c Release -r linux-arm64 -o publish/linux-arm64-net10.0 EvoPdf_Next_AspNetDemo_Linux.Arm64_net10.0.csproj # .NET 8, for the Dockerfile with the ASP.NET Core Runtime 8.0 base image dotnet publish -c Release -r linux-arm64 -o publish/linux-arm64-net8.0 EvoPdf_Next_AspNetDemo_Linux.Arm64_net8.0.csproj ``` -------------------------------- ### Dockerfile for Linux variant 5 (.NET 10.0) Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-docker/references/dockerfiles.md Dockerfile for Linux variant 5, based on .NET 10.0 ASP.NET Core runtime image. Installs EvoPdf dependencies, copies the published app, sets execute permissions for the EvoPdf HTML to PDF and PDF Processor runtimes, exposes port 27101, and starts the application. ```dockerfile FROM mcr.microsoft.com/dotnet/aspnet:10.0 # Install EvoPdf dependencies RUN apt-get update && \ apt-get install -y \ libnss3 \ libatk-bridge2.0-0 \ libcairo2 \ libpango-1.0-0 && \ rm -rf /var/lib/apt/lists/* # Set the working directory WORKDIR /app # Copy the published ASP.NET Core app files from the publish folder into the image COPY publish/ . # Ensure execute permissions for EvoPdf HTML to PDF runtime RUN chmod +x /app/evopdf_runtimes/linux-arm64/native/evopdf_loadhtml # Ensure execute permissions for EvoPdf PDF Processor runtime RUN chmod +x /app/evopdf_runtimes/linux-arm64/native/evopdf_pdfprocessor # Expose the port used by the app EXPOSE 27101 # Set the ASP.NET Core application to listen on port 27101 ENV ASPNETCORE_URLS=http://+:27101 # Start the application ENTRYPOINT ["dotnet", "EvoPdf_Next_AspNetDemo_Linux.Arm64.dll"] ``` -------------------------------- ### Dockerfile for Linux variant 6 (.NET 8.0 Jammy) Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-docker/references/dockerfiles.md Dockerfile for Linux variant 6, based on .NET 8.0 Jammy ASP.NET Core runtime image. Installs EvoPdf dependencies, copies the published app, sets execute permissions for the EvoPdf HTML to PDF and PDF Processor runtimes, exposes port 27101, and starts the application. ```dockerfile FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy # Install EvoPdf dependencies RUN apt-get update && \ apt-get install -y \ libnss3 \ libatk-bridge2.0-0 \ libcairo2 \ libpango-1.0-0 && \ rm -rf /var/lib/apt/lists/* # Set the working directory WORKDIR /app # Copy the published ASP.NET Core app files from the publish folder into the image COPY publish/ . # Ensure execute permissions for EvoPdf HTML to PDF runtime RUN chmod +x /app/evopdf_runtimes/linux-arm64/native/evopdf_loadhtml # Ensure execute permissions for EvoPdf PDF Processor runtime RUN chmod +x /app/evopdf_runtimes/linux-arm64/native/evopdf_pdfprocessor # Expose the port used by the app EXPOSE 27101 # Set the ASP.NET Core application to listen on port 27101 ENV ASPNETCORE_URLS=http://+:27101 # Start the application ENTRYPOINT ["dotnet", "EvoPdf_Next_AspNetDemo_Linux.Arm64.dll"] ``` -------------------------------- ### Publish EvoPdf Next Demo for Docker on Windows (dotnet publish) Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-docker/SKILL.md Publishes the EvoPdf Next ASP.NET demo for Windows x64. Use the .NET 10 command when building with the Dockerfile that uses the ASP.NET Core Runtime 10.0 base image, and the .NET 8 command for the Dockerfile with the 8.0 runtime. Output goes to the publish/windows-x64-net10.0 or publish/windows-x64-net8.0 folder. ```bash dotnet publish -c Release -r win-x64 -o publish/windows-x64-net10.0 EvoPdf_Next_AspNetDemo_Windows_net10.0.csproj ``` ```bash dotnet publish -c Release -r win-x64 -o publish/windows-x64-net8.0 EvoPdf_Next_AspNetDemo_Windows_net8.0.csproj ``` -------------------------------- ### Start and stop persistent renderer in ASP.NET Core with app.Lifetime Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-rendering-modes/SKILL.md Starts the persistent renderer when the ASP.NET Core application starts and stops it when the application stops, using the application lifetime events. ```csharp var app = builder.Build(); app.Lifetime.ApplicationStarted.Register(() => GlobalSettings.StartPersistentRenderer()); app.Lifetime.ApplicationStopping.Register(() => GlobalSettings.StopPersistentRenderer()); ``` -------------------------------- ### Set EvoPdf Next license key from environment variable Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-deployment/SKILL.md Set the license key once at startup (static). Without a key, output is watermarked in demo mode. Keys are perpetual and work offline with no activation call. ```csharp Licensing.LicenseKey = Environment.GetEnvironmentVariable("EVOPDF_LICENSE_KEY"); ``` -------------------------------- ### Add Attachments to Generated PDF from HTML - Full Controller Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-attachments/references/examples.md Complete ASP.NET Core MVC controller example for adding file attachments to a generated PDF. It creates an HtmlToPdfConverter, opens the Attachments panel via PdfViewerPreferences.PageMode = ViewerPageMode.UseAttachments, sets the PDF standard, embeds both an in-memory XML invoice and a text file from disk, then converts a URL or HTML string to PDF. Includes commented license key setup and ModelState validation. ```csharp using System; using System.IO; using System.Text; using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using EvoPdf_Next_AspNetDemo.Models; using EvoPdf_Next_AspNetDemo.Models.HTML_to_PDF; // Use EVO PDF Namespace using EvoPdf.Next; namespace EvoPdf_Next_AspNetDemo.Controllers.HTML_to_PDF { public class Add_Attachments_to_Generated_PDFController : Controller { private readonly IWebHostEnvironment m_hostingEnvironment; public Add_Attachments_to_Generated_PDFController(IWebHostEnvironment hostingEnvironment) { m_hostingEnvironment = hostingEnvironment; } public IActionResult Index() { var model = SetViewModel(); return View(model); } [HttpPost] public ActionResult ConvertHtmlToPdf(Add_Attachments_to_Generated_PDF_ViewModel model) { if (!ModelState.IsValid) { var errorMessage = ModelStateHelper.GetModelErrors(ModelState); throw new ValidationException(errorMessage); } // Set the license key received after purchase to use the library in licensed mode; leave it commented for demo mode // Licensing.LicenseKey = "your-license-key"; // Create a HTML to PDF converter object with default settings HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter(); // Open the Attachments panel on document load htmlToPdfConverter.PdfViewerPreferences.PageMode = ViewerPageMode.UseAttachments; // Sets the PDF standard for the generated document // Leave as None to generate a plain PDF without an accessibility structure tree or archival metadata htmlToPdfConverter.PdfDocumentOptions.PdfStandard = model.PdfStandard; // ===== Document-level attachments ===== // Attachments added via PdfDocumentOptions.AddFileAttachment appear // in the viewer's Attachments panel (opened with the paperclip icon // in Acrobat's left sidebar). They have no visible marker on any // page. Two factory methods cover the common cases: FromBytes for // in-memory data and FromFile for files on disk // FromBytes -- embed an in-memory XML invoice byte[] invoiceXmlBytes = Encoding.UTF8.GetBytes(BuildSampleInvoiceXml()); var xmlAttachment = PdfFileAttachment.FromBytes(invoiceXmlBytes, "invoice.xml"); xmlAttachment.MimeType = "application/xml"; xmlAttachment.Description = "Source XML invoice data"; xmlAttachment.Relationship = PdfAttachmentRelationship.Source; htmlToPdfConverter.PdfDocumentOptions.AddFileAttachment(xmlAttachment); // FromFile -- embed a file from disk string alphabetFilePath = Path.Combine(GetDemoTextsPath(), "Alphabet.txt"); var textAttachment = PdfFileAttachment.FromFile(alphabetFilePath); textAttachment.MimeType = "text/plain"; textAttachment.Description = "Sample alphabet text"; htmlToPdfConverter.PdfDocumentOptions.AddFileAttachment(textAttachment); byte[] outPdfBuffer = null; if (model.HtmlPageSource == "Url") { string url = model.Url; outPdfBuffer = htmlToPdfConverter.ConvertUrl(url); } else { string htmlWithForm = model.HtmlString; string baseUrl = model.BaseUrl; outPdfBuffer = htmlToPdfConverter.ConvertHtml(htmlWithForm, baseUrl); } ``` -------------------------------- ### Set up digital signature view model with defaults Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-security-signatures/references/examples.md Builds the view model for the digital signature example, setting default HTML, URL, base URL, and signature properties such as reason, location, contact, appearance, and text/image options. ```csharp private PDF_Digital_Signatures_ViewModel SetViewModel() { var model = new PDF_Digital_Signatures_ViewModel(); var contentRootPath = m_hostingEnvironment.ContentRootPath + "/wwwroot"; HttpRequest request = ControllerContext.HttpContext.Request; UriBuilder uriBuilder = new UriBuilder(); uriBuilder.Scheme = request.Scheme; uriBuilder.Host = request.Host.Host; if (request.Host.Port != null) uriBuilder.Port = (int)request.Host.Port; uriBuilder.Path = request.PathBase.ToString() + request.Path.ToString(); uriBuilder.Query = request.QueryString.ToString(); string currentPageUrl = uriBuilder.Uri.AbsoluteUri; string rootUrl = currentPageUrl.Substring(0, currentPageUrl.Length - "PDF_Digital_Signatures".Length); model.Url = "http://www.evopdf.com"; model.HtmlString = "Enter the HTML String to Convert and optionally set a Base URL if the HTML string references external resources by relative URLs"; model.BaseUrl = rootUrl; model.SignatureReason = "My Signature Reason"; model.SignatureLocation = "My Signature Location"; model.SignatureContact = "My Contact Information"; model.EnableAppearance = true; model.DisplayOnLastPage = false; model.AddSignatureText = true; model.SignatureText = "Signed by EVO PDF Software"; model.AddSignatureImage = true; return model; } ``` -------------------------------- ### Extract images asynchronously starting at a page Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-processor/references/examples.md Extracts images from a PDF asynchronously starting at a specified page using the ExtractImagesAsync method. ```csharp ExtractedImage[][] extractedImages = await pdfImagesExtractor.ExtractImagesAsync(inputPdfStream, startPageNumber); ExtractedImage[][] extractedImages = await pdfImagesExtractor.ExtractImagesAsync(inputPdfFile, startPageNumber); ``` -------------------------------- ### Run Linux x64 Demo Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-deployment/references/examples.md Run the published Linux x64 demo application from the publish/linux-x64-net10.0 directory. ```bash cd publish/linux-x64-net10.0 dotnet EvoPdf_Next_AspNetDemo_Linux_net10.0.dll ``` -------------------------------- ### Dockerfile for EvoPdf Next on Linux Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-docker/SKILL.md Base image for ASP.NET Core 8.0, installs required native dependencies (libnss3, libatk-bridge2.0-0, libcairo2, libpango-1.0-0), copies the published app, makes the native runtimes executable, exposes port 8080, and sets the entrypoint. ```dockerfile FROM mcr.microsoft.com/dotnet/aspnet:8.0 RUN apt-get update && apt-get install -y libnss3 libatk-bridge2.0-0 libcairo2 libpango-1.0-0 && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY publish/ . RUN chmod +x /app/evopdf_runtimes/linux-x64/native/evopdf_loadhtml \ && chmod +x /app/evopdf_runtimes/linux-x64/native/evopdf_pdfprocessor EXPOSE 8080 ENV ASPNETCORE_URLS=http://+:8080 ENTRYPOINT ["dotnet", "MyApp.dll"] ``` -------------------------------- ### Asynchronously convert PDF to images starting from a page Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-processor/references/examples.md Asynchronously converts PDF pages to images starting from a specified page number. ```csharp PdfPageImage[] pdfPageImages = await pdfToImageConverter.ConvertToImagesAsync(inputPdfStream, startPageNumber); PdfPageImage[] pdfPageImages = await pdfToImageConverter.ConvertToImagesAsync(inputPdfFile, startPageNumber); ``` -------------------------------- ### Before/After: Classic vs Next HTML to PDF conversion Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-classic-to-next-migration/SKILL.md Shows the minimal migration from EvoPdf Classic to EvoPdf.Next: swap the using directive, set the license key via Licensing.LicenseKey, and replace page size/footer options with the new API. ```csharp // Classic using EvoPdf; var c = new HtmlToPdfConverter(); c.LicenseKey = "..."; c.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4; c.PdfDocumentOptions.FitWidth = true; c.PdfFooterOptions.AddElement(new TextElement(0, 5, "Page &p; of &P;", font)); byte[] pdf = c.ConvertUrl(url); // Next using EvoPdf.Next; Licensing.LicenseKey = "..."; var c = new HtmlToPdfConverter(); c.FitBrowserWindowToPage(PdfPageSize.A4); c.PdfDocumentOptions.PdfHtmlFooter.Html = "
Page {page_number} of {total_pages}
"; c.PdfDocumentOptions.PdfHtmlFooter.Height = 30; byte[] pdf = c.ConvertUrl(url); ``` -------------------------------- ### Convert PDF to image files starting from a page Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-processor/references/examples.md Converts PDF pages to image files starting from a specified page number. ```csharp pdfToImageConverter.ConvertToImageFiles(inputPdfBytes, startPageNumber, outputDirectory, imageFileName); pdfToImageConverter.ConvertToImageFiles(inputPdfStream, startPageNumber, outputDirectory, imageFileName); pdfToImageConverter.ConvertToImageFiles(inputPdfFile, startPageNumber, outputDirectory, imageFileName); ``` -------------------------------- ### SinglePageOfWidth method example Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-page-setup/SKILL.md Shows how to create a single PDF page of a specified width in points. The example creates a receipt for 80 mm paper with 5 mm margins. ```csharp // A receipt for 80 mm paper, 5 mm margins converter.SinglePageOfWidth(227, 14); ``` -------------------------------- ### Asynchronously convert PDF to text starting from a page number Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-processor/references/examples.md Asynchronous conversion of a PDF to text starting from a specified page number. ```csharp string extractedText = await pdfToTextConverter.ConvertToTextAsync(inputPdfStream, startPageNumber); string extractedText = await pdfToTextConverter.ConvertToTextAsync(inputPdfFile, startPageNumber); ``` -------------------------------- ### Add lines, circles, and ellipse section to PDF with EvoPdf Source: https://github.com/evopdf/evopdf-agent-skills/blob/main/skills/evopdf-next-pdf-edit/references/examples.md C# examples for adding geometric shapes to an existing PDF using the EvoPdf editor. The first block shows adding lines with different line caps and a dashed line using CustomDashPattern. The second block shows adding circles with fill, stroke, and opacity options. The third block is the start of the ellipse rotation section, showing how to add a section label and ensure space on the page. ```csharp PdfLineCapStyle[] caps = { PdfLineCapStyle.Butt, PdfLineCapStyle.Round, PdfLineCapStyle.ProjectingSquare }; string[] capLabels = { "Butt", "Round", "ProjectingSquare" }; int section3RowTop = crtYPos; for (int i = 0; i < caps.Length; i++) { int lineY = section3RowTop + 8; var lineInfo = pdfEditor.AddLine(currentPage, new PdfLineElement(xLeft + 60, lineY, xLeft + 260, lineY) { LineColor = PdfColor.DarkBlue, LineStyle = new PdfLineStyle { LineWidth = 8f, LineCap = caps[i] } }); // Thin reference line to highlight the cap extension past the endpoints pdfEditor.AddLine(currentPage, new PdfLineElement(xLeft + 60, lineY, xLeft + 260, lineY) { LineColor = PdfColor.White, LineStyle = new PdfLineStyle { LineWidth = 0.5f } }); int capBottom = AddCaption(pdfEditor, ref currentPage, labelFont, capLabels[i], xLeft + 270, lineY - 5, 150); int lineBottom = (int)lineInfo.LastPageRectangle.Bounds.Bottom; section3RowTop = Math.Max(lineBottom, capBottom) + 5; } crtYPos = section3RowTop + ySeparator; // Dashed line using CustomDashPattern var dashLineInfo = pdfEditor.AddLine(currentPage, new PdfLineElement(xLeft, crtYPos, xLeft + 380, crtYPos) { LineColor = PdfColor.DarkRed, LineStyle = new PdfLineStyle { LineWidth = 2f, CustomDashPattern = new float[] { 10f, 4f, 2f, 4f }, DashPhase = 0f } }); int dashCapBottom = AddCaption(pdfEditor, ref currentPage, labelFont, "CustomDashPattern [10, 4, 2, 4]", xLeft, (int)dashLineInfo.LastPageRectangle.Bounds.Bottom + 5, 250); crtYPos = dashCapBottom + ySeparator; ``` ```csharp // ===== Section 4: PdfCircleElement ===== EnsureSpaceOnPage(ref crtYPos, ref currentPage, 160, pdfEditor, contentHeight, topMargin); crtYPos = AddSectionLabel(pdfEditor, ref currentPage, sectionFont, "4. PdfCircleElement (filled, stroked, opacity)", xLeft, crtYPos, ySeparator); var circle1Info = pdfEditor.AddCircle(currentPage, new PdfCircleElement(xLeft + 40, crtYPos + 40, 30) { FillColor = PdfColor.Tomato, BorderColor = PdfColor.DarkRed, Border = new PdfLineStyle { LineWidth = 1.5f } }); int circle1CapBottom = AddCaption(pdfEditor, ref currentPage, labelFont, "filled + border", xLeft + 10, (int)circle1Info.LastPageRectangle.Bounds.Bottom + 5, 90); var circle2Info = pdfEditor.AddCircle(currentPage, new PdfCircleElement(xLeft + 140, crtYPos + 40, 30) { FillColor = null, BorderColor = PdfColor.DarkBlue, Border = new PdfLineStyle { LineWidth = 2f } }); int circle2CapBottom = AddCaption(pdfEditor, ref currentPage, labelFont, "stroke only", xLeft + 110, (int)circle2Info.LastPageRectangle.Bounds.Bottom + 5, 90); var circle3Info = pdfEditor.AddCircle(currentPage, new PdfCircleElement(xLeft + 240, crtYPos + 40, 30) { FillColor = PdfColor.Purple, FillOpacity = 0.4f, BorderColor = PdfColor.Purple, BorderOpacity = 0.7f, Border = new PdfLineStyle { LineWidth = 1f } }); int circle3CapBottom = AddCaption(pdfEditor, ref currentPage, labelFont, "translucent", xLeft + 210, (int)circle3Info.LastPageRectangle.Bounds.Bottom + 5, 90); crtYPos = Math.Max(Math.Max(circle1CapBottom, circle2CapBottom), circle3CapBottom) + ySeparator; ``` ```csharp // ===== Section 5: PdfEllipseElement (rotation, axis-aligned vs QuadPoints) ===== EnsureSpaceOnPage(ref crtYPos, ref currentPage, 180, pdfEditor, contentHeight, topMargin); crtYPos = AddSectionLabel(pdfEditor, ref currentPage, sectionFont, "5. PdfEllipseElement rotation - Bounds (axis-aligned) vs QuadPoints (rotated)", xLeft, crtYPos, ySeparator); ```