PdfSharp.Maui
1.0.5
dotnet add package PdfSharp.Maui --version 1.0.5
NuGet\Install-Package PdfSharp.Maui -Version 1.0.5
<PackageReference Include="PdfSharp.Maui" Version="1.0.5" />
paket add PdfSharp.Maui --version 1.0.5
#r "nuget: PdfSharp.Maui, 1.0.5"
// Install PdfSharp.Maui as a Cake Addin #addin nuget:?package=PdfSharp.Maui&version=1.0.5 // Install PdfSharp.Maui as a Cake Tool #tool nuget:?package=PdfSharp.Maui&version=1.0.5
PdfSharp.Maui
PdfSharp.Maui is a Microsoft.Maui library for converting any Maui.View into PDF. It usesPdfSharp.
Demo
By following (Demo) folder, you will see screenshots, and PDF view generated from.
Usage
- Init :
var pdfManager = new PdfManager()
- Generate :
var pdf = pdfManager.GeneratePdfFromView(view, PageOrientation.Landscape, PageSize.A4, PdfStyleUniversal)
- Save :
Utils.PdfSave.Save(pdf, "name.pdf","location")
Features
- Universal style and Platform Specific(WYSIWYG) Pdf rendering
- Custom Fonts (You should provide Font while creating
PdfManager
)- Image rendering. (It also supports
png
images)- Custom renderer (Write your own renderer for your own custom view)
- Paper size & orientation support
- Do not render option : by using
pdf:PdfRendererAttributes.ShouldRender="False"
you can ignore the view from rendering- Gradient background color support (
LinearGradientBrush
andSolidColorBrush
)
Limitations
- It does not support
RadialGradientBrush
yet.png
images will be converted intojpeg
in android.
ListView & CollectionView Rendering
Due to template style of these view library only renders as basic listview. Therefore you should implement your own delegate classes derived from
PdfListViewRendererDelegate
orPdfCollectionViewRendererDelegate
. You will find the sample list view delegate atPdfSharp.Maui.Sample/CustomListViewRendererDelegate.cs
Custom PDF Renderer
Its possible to write your own renderer, for your own custom view. You should mark your class with
PdfRenderer
attribute, then you have to create PdfManager by giving the assembly.
[PdfRenderer(ViewType = typeof(YourView))]
public class PdfCustomViewRenderer : PdfRendererBase<YourView>
{
public override void CreatePDFLayout(XGraphics page, YourView view, XRect bounds, double scaleFactor)
{
XFont font = new XFont(GlobalFontSettings.DefaultFontName, 14 * scaleFactor);
page.DrawRectangle(view.GetBackgroundBrush(), bounds);
page.DrawString("Sample text in the page", font, XBrushes.Black, bounds, XStringFormats.Center);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-android34.0 is compatible. net8.0-browser was computed. net8.0-ios was computed. net8.0-ios17.2 is compatible. net8.0-maccatalyst was computed. net8.0-maccatalyst17.2 is compatible. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net8.0-windows10.0.19041 is compatible. |
-
net8.0
- Microsoft.Maui.Controls (>= 8.0.7)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.7)
- PDFsharp (>= 6.0.0)
-
net8.0-android34.0
- Microsoft.Maui.Controls (>= 8.0.7)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.7)
- PDFsharp (>= 6.0.0)
-
net8.0-ios17.2
- Microsoft.Maui.Controls (>= 8.0.7)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.7)
- PDFsharp (>= 6.0.0)
-
net8.0-maccatalyst17.2
- Microsoft.Maui.Controls (>= 8.0.7)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.7)
- PDFsharp (>= 6.0.0)
-
net8.0-windows10.0.19041
- Microsoft.Maui.Controls (>= 8.0.7)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.7)
- PDFsharp (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.