Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x' # SDK Version to use.
dotnet-version: '10.0.x' # SDK Version to use.

- name: Build project
run: dotnet build HtmlPdfPlus.sln -c Release

- name: Install Playwright browsers
run: pwsh src/TestHtmlPdfCliPlus/bin/Release/net9.0/playwright.ps1 install --with-deps chromium
run: pwsh src/TestHtmlPdfCliPlus/bin/Release/net10.0/playwright.ps1 install --with-deps chromium

- name: Run test cases
run: dotnet test -c Release --no-build
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup .NET
if: matrix.language == 'csharp'
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
dotnet-version: '10.0.x'

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x' # SDK Version to use.
dotnet-version: '10.0.x' # SDK Version to use.

- name: Setup Version
id: setup_version
Expand Down
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# This stage is used when running from VS in fast mode (Default for Debug configuration)
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
EXPOSE 8080
EXPOSE 8081

USER root

# Install Google Chrome (133.0.6943.* - Same playwright 1.51.0) Stable and fonts
# Install Google Chrome Stable and fonts
# Note: this installs the necessary libs to make the browser work.
RUN apt-get update && apt-get install gnupg wget -y && \
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg
RUN wget -q https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_134.0.6998.35-1_amd64.deb
RUN wget -q https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stablegoogle-chrome-stable_142.0.7444.162-1_amd64.deb
RUN apt-get -y update
RUN apt-get install ./google-chrome-stable_134.0.6998.35-1_amd64.deb -y --no-install-recommends
RUN apt-get install ./google-chrome-stable_142.0.7444.162-1_amd64.deb -y --no-install-recommends

# Clean up
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ./google-chrome-stable_134.0.6998.35-1_amd64.deb
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ./google-chrome-stable_142.0.7444.162-1_amd64.deb

# This stage (pre-installed playwright with Google Chrome 133.0.6943.*) install the .net 9 runtime and used to build the service project
FROM mcr.microsoft.com/playwright/dotnet:v1.51.0 AS build
# This stage (pre-installed playwright with Google Chrome install the .net 10 runtime and used to build the service project
FROM mcr.microsoft.com/playwright/dotnet:v1.56.0 AS build

USER root

Expand All @@ -29,12 +29,12 @@ RUN rm -rf /ms-playwright/webkit*
RUN rm -rf /ms-playwright/chromium-*
RUN rm -rf /usr/share/dotnet

# Download the dotnet install script for .net 9
# Download the dotnet install script for .net
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
RUN chmod +x ./dotnet-install.sh

# Run it against a version you want
RUN ./dotnet-install.sh --channel 9.0 --install-dir /usr/share/dotnet/
RUN ./dotnet-install.sh --channel 10.0 --install-dir /usr/share/dotnet/

ARG BUILD_CONFIGURATION=Release

Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
- [FAQ](#faq)

## Project Description
HtmlPdfPlus is a modern and lightweight library for **.Net9, .Net8 and NetStandard2.1** that allows you to convert HTML or RAZOR pages to PDF with high fidelity.
HtmlPdfPlus is a modern and lightweight library for **.Net10, .Net9 and .Net8** that allows you to convert HTML or RAZOR pages to PDF with high fidelity.

It is a scalable and flexible solution that can be used in client-server mode or only server. It supports CSS and JavaScript, and it is easy to integrate with your application.

You can customize the PDF settings, such as page size and margins, and add headers and footers to your PDF files. HtmlPdfPlus is a powerful tool that can help you generate PDF files from HTML or RAZOR pages with ease.

This library was built using the [Playwright](https://playwright.dev/dotnet/) (engine to automate **Chromium, Firefox, and WebKit** with a single API). Playwright is built to enable cross-browser web automation that is evergreen, capable, reliable, and fast.

The current version (V.1.51.0) of **Playwright** supports **only the Chromium browser** for the PDF API.
The current version (V.1.56.0) of **Playwright** supports **only the Chromium browser** for the PDF API.

## Features
[**Top**](#table-of-contents)
Expand All @@ -61,8 +61,13 @@ The current version (V.1.51.0) of **Playwright** supports **only the Chromium br
- Disable features to improve/ balance performance (minify, compress and log)

### What's new in the latest version
- **v1.0.1 (latest version)**
- Updated Playwright to version 1.56.0
- Adjusted package reference for target framework (removed NetStandard2.1)
- Updated documentation
- include target .NET 10.0

- **v1.0.0 (latest version)**
- **v1.0.0
- Updated Playwright to version 1.51.0
- Adjusted package reference for target framework
- Updated documentation
Expand Down Expand Up @@ -106,7 +111,7 @@ The current version (V.1.51.0) of **Playwright** supports **only the Chromium br
## Prerequisites
[**Top**](#table-of-contents)

- .NET 8 or .NET 9 SDK
- .NET 8, .NET 9 or .NET 10 SDK
- Visual Studio 2022 or later
- Playwright (Installed and configured for your O.S)

Expand Down Expand Up @@ -377,11 +382,11 @@ This project suggests a containerization example that **reduces the final image
To achieve this reduction, the biggest challenge was controlling the necessary dependencies and keeping only the minimum for execution in a headless shell.

Basically, what we did was:
- Use the base image from mcr.microsoft.com/dotnet/aspnet:9.0
- Use the image from cr.microsoft.com/playwright/dotnet:v1.51.0 for build
- Use the base image from mcr.microsoft.com/dotnet/aspnet:10.0
- Use the image from cr.microsoft.com/playwright/dotnet:v1.56.0 for build
- Removing unnecessary browser and driver installations
- For .NET 9, we removed the default installation (.NET 8)
- We installed the .NET 9 SDK version for the build phase
- we removed the default installation (.NET x)
- We installed the .NET 10 SDK version for the build phase
- Copy the required folder (pre-installed) to run Playwright
- Install Google Chrome Stable , fonts and install the necessary libs to make the browser work.
- Set environment variable for Playwright
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.3" />
<PackageReference Include="NUglify" Version="1.21.13" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.3" />
<PackageReference Include="NUglify" Version="1.21.13" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.3" />
<PackageReference Include="NUglify" Version="1.21.13" />
<PackageReference Include="SuperSimpleTcp" Version="3.0.17" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.0" />
<PackageReference Include="SuperSimpleTcp" Version="3.0.20" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.3" />
<PackageReference Include="NUglify" Version="1.21.13" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.3" />
<PackageReference Include="NUglify" Version="1.21.13" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.3" />
<PackageReference Include="NUglify" Version="1.21.13" />
<PackageReference Include="SuperSimpleTcp" Version="3.0.17" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="SuperSimpleTcp" Version="3.0.20" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.3" />
<PackageReference Include="NUglify" Version="1.21.13" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.3" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
22 changes: 9 additions & 13 deletions src/HtmlPdfPlus.Client/HtmlPdfPlus.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"/>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
</ItemGroup>
</Target>
<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net10.0;net9.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>1701;1702;NU5100;NU5104</NoWarn>
Expand Down Expand Up @@ -59,20 +59,16 @@
<IncludeAssets>HtmlPdfPlus.Shared.dll</IncludeAssets>
</ProjectReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.1'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
<PackageReference Include="NUglify" Version="1.21.13" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net8.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
<PackageReference Include="NUglify" Version="1.21.13" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="NUglify" Version="1.21.17" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net9.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.3" />
<PackageReference Include="NUglify" Version="1.21.13" />
<PackageReference Include="System.Text.Json" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.11" />
<PackageReference Include="NUglify" Version="1.21.17" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net10.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
<PackageReference Include="NUglify" Version="1.21.17" />
</ItemGroup>
</Project>
Loading
Loading