All Projects → ststeiger → Pdfsharpcore

ststeiger / Pdfsharpcore

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)

Programming Languages

csharp
926 projects

Projects that are alternatives of or similar to Pdfsharpcore

Django Easy Pdf
PDF views, the easy way
Stars: ✭ 324 (-10%)
Mutual labels:  pdf
Puremvc Csharp Standard Framework
PureMVC Standard Framework for C#
Stars: ✭ 335 (-6.94%)
Mutual labels:  xamarin
Xamarin Fingerprint
Xamarin and MvvMCross plugin for authenticate a user via fingerprint sensor
Stars: ✭ 354 (-1.67%)
Mutual labels:  xamarin
Eshoponcontainers
Cross-platform .NET sample microservices and container based application that runs on Linux Windows and macOS. Powered by .NET 6, Docker Containers and Azure Kubernetes Services. Supports Visual Studio, VS for Mac and CLI based environments with Docker CLI, dotnet CLI, VS Code or any other code editor.
Stars: ✭ 19,397 (+5288.06%)
Mutual labels:  xamarin
Maroto
A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple.
Stars: ✭ 334 (-7.22%)
Mutual labels:  pdf
Universalviewer
A community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
Stars: ✭ 343 (-4.72%)
Mutual labels:  pdf
Open Source Xamarin Apps
📱 Collaborative List of Open Source Xamarin Apps
Stars: ✭ 318 (-11.67%)
Mutual labels:  xamarin
Bluetoothle
Easy to use, cross platform, REACTIVE BluetoothLE Plugin for Xamarin
Stars: ✭ 357 (-0.83%)
Mutual labels:  xamarin
Latexdraw
A vector drawing editor for LaTeX (JavaFX).
Stars: ✭ 336 (-6.67%)
Mutual labels:  pdf
Jupyterlab Latex
JupyterLab extension for live editing of LaTeX documents
Stars: ✭ 349 (-3.06%)
Mutual labels:  pdf
Prism Samples Forms
Samples that demonstrate how to use various Prism features with Xamarin.Forms
Stars: ✭ 327 (-9.17%)
Mutual labels:  xamarin
Pdf Bookmark
pdf bookmark generator 目录 书签 大纲
Stars: ✭ 327 (-9.17%)
Mutual labels:  pdf
Lightnovel Crawler
Download and generate e-books from online sources.
Stars: ✭ 344 (-4.44%)
Mutual labels:  pdf
Itextsharp.lgplv2.core
iTextSharp.LGPLv2.Core is an unofficial port of the last LGPL version of the iTextSharp (V4.1.6) to .NET Core
Stars: ✭ 322 (-10.56%)
Mutual labels:  pdf
Ammyui
Ammy language repository
Stars: ✭ 356 (-1.11%)
Mutual labels:  xamarin
Percollate
A command-line tool to turn web pages into beautiful, readable PDF, EPUB, or HTML docs.
Stars: ✭ 3,535 (+881.94%)
Mutual labels:  pdf
Technical Ebooks
PDFs for programming tutorials.
Stars: ✭ 342 (-5%)
Mutual labels:  pdf
Cermine
Content ExtRactor and MINEr
Stars: ✭ 357 (-0.83%)
Mutual labels:  pdf
E Books
IT technical related e-books and PPT information, continuous updating. For those in need, Keep real, peace and love.
Stars: ✭ 357 (-0.83%)
Mutual labels:  pdf
Mvvmcross
The .NET MVVM framework for cross-platform solutions, including Xamarin.iOS, Xamarin.Android, Windows and Mac.
Stars: ✭ 3,594 (+898.33%)
Mutual labels:  xamarin

PdfSharpCore

PdfSharpCore is a partial port of PdfSharp.Xamarin for .NET Standard Additionally MigraDoc has been ported as well (from version 1.32). Images have been implemented with ImageSharp, which is still in Alpha. They State on their readme that it is still in Alpha status and shouldn't be used in productive environments. Since I didn't find any good alternatives it's still used.

ImageSharp being Alpha isn't a big issue either since this code isn't by far done yet. So please chime in ;)

PdfSharp.Xamarin is a partial port of PdfSharp for iOS and Android using Xamarin, it allows for creation and modification of PDF files.

Example project

There was an example project here.
I've removed it from this project, and put it into a separate solution. You can find it here.
There's a default font-resolver in FontResolver.cs.
It should work on Windows, Linux, OSX and Azure.
Some limitations apply.
See open issues.

Example usage

//See the "Example" Project for a MigraDoc example
static void Main(string[] args)
{
    GlobalFontSettings.FontResolver = new FontResolver();
    
    var document = new PdfDocument();
    var page = document.AddPage();
    var gfx = XGraphics.FromPdfPage(page);
    var font = new XFont("OpenSans", 20, XFontStyle.Bold);
            
    gfx.DrawString("Hello World!", font, XBrushes.Black, new XRect(20, 20, page.Width, page.Height), XStringFormats.Center);

    document.Save("test.pdf");
}

//This implementation is obviously not very good --> Though it should be enough for everyone to implement their own.
public class FontResolver : IFontResolver
{
    public byte[] GetFont(string faceName)
    {
        using(var ms = new MemoryStream())
        {
            using(var fs = File.Open(faceName, FileMode.Open))
            {
                fs.CopyTo(ms);
                ms.Position = 0;
                return ms.ToArray();
                }
            }
        }
        public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic)
        {
            if (familyName.Equals("OpenSans", StringComparison.CurrentCultureIgnoreCase))
            {
                if (isBold && isItalic)
                {
                    return new FontResolverInfo("OpenSans-BoldItalic.ttf");
                }
                else if (isBold)
                {
                    return new FontResolverInfo("OpenSans-Bold.ttf");
                }
                else if (isItalic)
                {
                    return new FontResolverInfo("OpenSans-Italic.ttf");
                }
                else
                {
                    return new FontResolverInfo("OpenSans-Regular.ttf");
                }
            }
            return null;
        }
    }
}

License

Copyright (c) 2005-2007 empira Software GmbH, Cologne (Germany)
Modified work Copyright (c) 2016 David Dunscombe

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].