PDFiumSharp | .NET wrapper around Google 's PDFium library | Document Editor library
kandi X-RAY | PDFiumSharp Summary
kandi X-RAY | PDFiumSharp Summary
The PDFiumSharp library is a C#/.NET wrapper around the PDFium library. It enables .NET developers to create, open, manipulate, render and save PDF documents.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PDFiumSharp
PDFiumSharp Key Features
PDFiumSharp Examples and Code Snippets
Community Discussions
Trending Discussions on PDFiumSharp
QUESTION
I'm trying to add a custom font (otf file or for testing purpose ttf) to my PDF document to render text page objects with. The rendered text is always the same gibberish like ÿÿÿÿÿÿe
('e' might be the last char of my string or a random character). Creating, rendering and adding other objects like paths or images are working fine. So I'm guessing the font isn't loaded correctly.
I'm using an updated version of the C# wrapper PDFiumSharp ( https://github.com/ArgusMagnus/PDFiumSharp ), which provides the following methods: FPDFText_LoadFont(document, FontType, IsCid, byte[] fontData)
and FPDFPageObj_CreateTextObj(document, FPDF_Font font, size)
. The wiki of PDFiumSharp states that through LoadFont
the font is loaded into the document. The code snippet following runs through without problems (so fontpath is correct, can be loaded and the text object can be created).
I exchanged the pdfium.dll with the newest one from https://github.com/bblanchon/pdfium-binaries, which includes the entry point FPDF_LoadFont too.
There is also another entry point FPDF_InitLibraryWithConfig
, which gets a FPDF_LIBRARY_CONFIG
as argument. This config holds a readonly field IntPtr _userFontPaths
, which might me usable somehow, but I haven't find a way to set this.
ANSWER
Answered 2019-Jul-15 at 10:49Ok, the problem was again in the wrapper:
The function bool FPDFText_SetText(FPDF_PAGEOBJECT text_object, [MarshalAs(UnmanagedType.LPStr)] string text)
needed a LPStr
. Changing it to LPWStr
did the trick.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PDFiumSharp
PDFium.Windows contains the native PDFium binaries for windows. Either install this package or provide the binaries yourself (put pdfium_x64.dll, pdfium_x86.dll in the application directory).
PDFiumSharp contains the core package. With this you can create, open, manipulate, render and save PDF documents. PdfPages can be rendered to PDFiumBitmaps (which are simply memory buffers). This package depends on the presence of the native PDFium binaries.
PDFiumSharp.GdiPlus extends the PdfPage class with extension methods to render to Bitmaps.
PDFiumSharp.Wpf extends the PdfPage class with extension methods to render to WriteableBitmaps.
PDFiumSharp.Xwt extends the PdfPage class with extension methods to render to BitmapImages.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page