VOOZH about

URL: https://www.nuget.org/packages/Weasyprint.Wrapped/

⇱ NuGet Gallery | Weasyprint.Wrapped 10.1.0




Weasyprint.Wrapped 10.1.0

dotnet add package Weasyprint.Wrapped --version 10.1.0
 
 
NuGet\Install-Package Weasyprint.Wrapped -Version 10.1.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Weasyprint.Wrapped" Version="10.1.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Weasyprint.Wrapped" Version="10.1.0" />
 
Directory.Packages.props
<PackageReference Include="Weasyprint.Wrapped" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Weasyprint.Wrapped --version 10.1.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Weasyprint.Wrapped, 10.1.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Weasyprint.Wrapped@10.1.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Weasyprint.Wrapped&version=10.1.0
 
Install as a Cake Addin
#tool nuget:?package=Weasyprint.Wrapped&version=10.1.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

👁 build-test-code-scan

Introduction

Wrapper around the weasyprint library which allows you to print html to a pdf file. This package does not require any external software or packages to be installed in order to use weasyprint.

Getting started

Installation

👁 NuGet Badge

dotnet add package Weasyprint.Wrapped

Usage

You might want to provide the printer class using your DI Container.

  1. Initialize
    This will unzip the needed asset, it is best done during startup procedure. The printer will check if the asset is already unzipped, so the process is only done once (or when the package is upgraded and the version changed).
await new Printer().Initialize();
  1. Print
await new Printer().Print("<html><body><h1>TEST</h1></body></html>");

Warning

There are resources which will be extracted during initialization, the size of it is:

  • +-29 MB zipped resource (official standalone windows executable) which will be unzipped in the same folder (for Windows).
  • +-26 MB zipped resource (standalone build weasyprint) which will be unzipped in the same folder (for Linux).

Extra resources

References

Thanks to all these great repos and the guys maintaining them!!!

Weasyprint CLI

The weasyprint program takes at least two arguments:

weasyprint [options] <input> <output>

  • input: URL or filename of the HTML input, or - for stdin.

  • output: Filename where output is written, or - for stdout.

  • -e <encoding>, --encoding <encoding>: Force the input character encoding.

  • -s <stylesheet>, --stylesheet <stylesheet> URL or filename for a user CSS stylesheet.

This option can be passed multiple times.

  • -m <media-type>, --media-type <media-type> Media type to use for @media, defaults to print.

  • -u <base-url>, --base-url <base-url> Base for relative URLs in the HTML input, defaults to the input’s own filename or URL or the current directory for stdin.

  • -a <attachment>, --attachment <attachment> URL or filename of a file to attach to the PDF document. This option can be passed multiple times.

  • --pdf-identifier <pdf-identifier> PDF file identifier.

  • --pdf-variant <pdf-variant> PDF variant to generate.

    Possible choices: pdf/a-1b, pdf/a-2b, pdf/a-3b, pdf/a-4b, pdf/ua-1.

  • --pdf-version <pdf-version> PDF version number.

  • --pdf-forms Include PDF forms.

  • --uncompressed-pdf Do not compress PDF content, mainly for debugging purpose.

  • --custom-metadata Include custom HTML meta tags in PDF metadata.

  • -p, --presentational-hints Follow HTML presentational hints.

  • --optimize-images Optimize size of embedded images with no quality loss.

  • -j <jpeg-quality>, --jpeg-quality <jpeg-quality> JPEG quality between 0 (worst) to 95 (best).

  • --full-fonts Embed unmodified font files when possible.

  • --hinting Keep hinting information in embedded fonts.

  • -c <cache-folder>, --cache-folder <cache-folder> Store cache on disk instead of memory, folder is created if needed and cleaned after the PDF is generated.

  • -D <dpi>, --dpi <dpi> Set maximum resolution of images embedded in the PDF.

  • -v, --verbose Show warnings and information messages.

  • -d, --debug Show debugging messages.

  • -q, --quiet Hide logging messages.

  • --version Print WeasyPrint’s version number and exit.

  • -i, --info Print system information and exit.

  • -O <optimize-size>, --optimize-size <optimize-size> Deprecated, use other options instead.

    Possible choices: images, fonts, hinting, pdf, all, none. This option can be passed multiple times.

  • -h, --help: Show this help message and exit.

Contribute

Create test package and run example

Windows:

.\build-on-windows.ps1

Linux (docker is needed):

./build-on-linux.sh

Create package:

cd .\src\Weasyprint.Wrapped\
dotnet pack -p:PackageVersion=0.0.25 --output nupkgs

The sample projects use a local project reference to Weasyprint.Wrapped. Building the solution does not automatically copy the generated assets/standalone-*.zip files into the sample app output, so before running the samples you should first run the appropriate asset build script above and ensure the generated zip is copied to the sample output directory.

Error in tests

The following error might be thrown when running the tests on Windows:

(process:13448): GLib-GIO-WARNING **: 17:21:45.816: Unexpectedly, UWP app `Microsoft.OutlookForWindows_1.2023.1114.100_x64__8wekyb3d8bbwe' (AUMId `Microsoft.OutlookForWindows_8wekyb3d8bbwe!Microsoft.OutlookforWindows') supports 1 extensions but has no verbs

Check here for the answer: https://stackoverflow.com/questions/67607643/what-does-this-warning-mean-it-happens-every-time-i-restart-the-node-process#answer-67715630

Building assets

Windows (build-on-windows.ps1 does approximately this)

Basically it does the same thing as the original exe generation of weasyprint does (https://github.com/Kozea/WeasyPrint/blob/main/.github/workflows/exe.yml), but wrapped into a ps1 script and generating a one directory solution instead a one file solution. Here are the steps:

Linux (build-on-linux.sh does approximately this)

  • Starting a docker image with an Ubunut 22.04
  • Update the image to the latest packages
  • Installing python3 and all the dependencies for weasyprint inside the docker image
  • Installing weasyprint and pyinstaller using pip
  • Use pyinstaller to create a standalone executable for Linux (https://pyinstaller.org/en/stable/usage.html#cmdoption-D)
  • Chek the newly created executable in a new clean docker image to make sure it works and has all the needed dependencies
  • Pack the executable into the resources zip for Linux

Help

  • Check PATH in python
.\python.exe -c "import os; print(*os.environ['PATH'].split(os.pathsep), sep='\n')"
Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Weasyprint.Wrapped:

Package Downloads
Avae.Printables

Printing for avalonia

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.1.0 1,020 4/18/2026
10.0.3 265 4/9/2026
10.0.2 164 4/2/2026
10.0.1 204 3/28/2026
9.0.0 219 3/12/2026
8.0.3 149 3/12/2026
7.0.1 49,471 1/5/2025
6.0.1 150,958 3/2/2024
6.0.0 1,059 3/2/2024
5.0.0 28,900 1/1/2024
4.0.1 3,728 1/1/2024
4.0.0 42,330 6/18/2023
3.0.4 1,310 5/24/2023
3.0.3 1,033 5/24/2023
3.0.1 58,204 12/22/2022
3.0.0 14,909 10/21/2022
2.0.1 1,501 10/21/2022
Loading failed