Coder Social home page Coder Social logo

pdfsharp.maui's Introduction

PdfSharp.Maui

PdfSharp.Maui is a Microsoft.Maui library for converting any Maui.View into PDF. It usesPdfSharp.

NuGet FOSSA Status

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 and SolidColorBrush)

Limitations

  • It does not support RadialGradientBrush yet.
  • png images will be converted into jpeg 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 or PdfCollectionViewRendererDelegate. You will find the sample list view delegate at PdfSharp.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);
		}
	}

License

FOSSA Status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.