mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-01-18 19:51:24 +08:00
update package icon #96 and readme
updates nuget package definition to use new format of package icon as required by #96. add readme information for hyperlinks and truetype fonts #8.
This commit is contained in:
67
README.md
67
README.md
@@ -5,12 +5,27 @@
|
||||
[](https://dev.azure.com/pdfpig/pdfpig/_build/latest?definitionId=1&branchName=master)
|
||||
[](https://codecov.io/gh/UglyToad/PdfPig)
|
||||
[](https://gitter.im/pdfpig/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
[](https://www.nuget.org/packages/PdfPig/)
|
||||
|
||||
This project allows users to read and extract text and other content from PDF files. In addition the library can be used to create simple PDF documents
|
||||
containing text and geometrical shapes.
|
||||
|
||||
This project aims to port [PDFBox](https://github.com/apache/pdfbox) to C#.
|
||||
|
||||
**Migrating to 0.1.x from 0.0.x?** Use this guide: [migration to 0.1.x](https://github.com/UglyToad/PdfPig/wiki/Migration-0.0.X-to-0.1.0).
|
||||
|
||||
## Installation ##
|
||||
|
||||
The package is available via the releases tab or from Nuget:
|
||||
|
||||
https://www.nuget.org/packages/PdfPig/
|
||||
|
||||
Or from the package manager console:
|
||||
|
||||
> Install-Package PdfPig
|
||||
|
||||
While the version is below 1.0.0 minor versions will change the public API without warning (SemVer will not be followed until 1.0.0 is reached).
|
||||
|
||||
## Get Started ##
|
||||
|
||||
The simplest usage at this stage is to open a document, reading the words from every page:
|
||||
@@ -28,7 +43,7 @@ The simplest usage at this stage is to open a document, reading the words from e
|
||||
}
|
||||
}
|
||||
|
||||
New in v0.0.5 - To create documents use the class ```PdfDocumentBuilder```. Though they are deprecated within the PDF specification the Standard 14 fonts provide a quick way to get started:
|
||||
To create documents use the class ```PdfDocumentBuilder```. The Standard 14 fonts provide a quick way to get started:
|
||||
|
||||
PdfDocumentBuilder builder = new PdfDocumentBuilder();
|
||||
|
||||
@@ -43,19 +58,7 @@ New in v0.0.5 - To create documents use the class ```PdfDocumentBuilder```. Thou
|
||||
|
||||
File.WriteAllBytes(@"C:\git\newPdf.pdf", documentBytes);
|
||||
|
||||
Each font must be registered with the PdfDocumentBuilder prior to use enable pages to share the font resources. Currently only Standard 14 fonts and TrueType fonts (.ttf) are supported.
|
||||
|
||||
## Installation ##
|
||||
|
||||
The package is available via the releases tab or from Nuget:
|
||||
|
||||
https://www.nuget.org/packages/PdfPig/
|
||||
|
||||
Or from the package manager console:
|
||||
|
||||
> Install-Package PdfPig
|
||||
|
||||
While the version is below 1.0.0 minor versions will change the public API without warning (SemVer will not be followed until 1.0.0 is reached).
|
||||
Each font must be registered with the PdfDocumentBuilder prior to use enable pages to share the font resources. Only Standard 14 fonts and TrueType fonts (.ttf) are supported.
|
||||
|
||||
## Usage ##
|
||||
|
||||
@@ -83,15 +86,22 @@ Encrypted documents can be opened by PdfPig. To provide an owner or user passwor
|
||||
|
||||
using (PdfDocument document = PdfDocument.Open(@"C:\my-file.pdf", new ParsingOptions { Password = "password here" }))
|
||||
|
||||
Since this is alpha software the consumer should wrap all access in a ```try catch``` block since it is extremely likely to throw exceptions. As a fallback you can try running PDFBox using [IKVM](https://www.ikvm.net/) or using [PDFsharp](http://www.pdfsharp.net) or by a native library wrapper using [docnet](https://github.com/GowenGit/docnet).
|
||||
You can also provide a list of passwords to try:
|
||||
|
||||
using (PdfDocument document = PdfDocument.Open(@"C:\file.pdf", new ParsingOptions
|
||||
{
|
||||
Passwords = new List<string> { "One", "Two" }
|
||||
}))
|
||||
|
||||
The document contains the version of the PDF specification it complies with, accessed by ```document.Version```:
|
||||
|
||||
decimal version = document.Version;
|
||||
|
||||
### Document Creation ###
|
||||
### Document Creation (0.0.5) ###
|
||||
|
||||
New in v0.0.5 - The ```PdfDocumentBuilder``` creates a new document with no pages or content. First, for text content, a font must be registered with the builder. Currently this supports Standard 14 fonts provided by Adobe by default and TrueType format fonts.
|
||||
The ```PdfDocumentBuilder``` creates a new document with no pages or content.
|
||||
|
||||
For text content, a font must be registered with the builder. This library supports Standard 14 fonts provided by Adobe by default and TrueType format fonts.
|
||||
|
||||
To add a Standard 14 font use:
|
||||
|
||||
@@ -154,9 +164,9 @@ The ```PdfDocument``` provides access to the document metadata as ```DocumentInf
|
||||
string title = document.Information.Title;
|
||||
// etc...
|
||||
|
||||
### Document Structure ###
|
||||
### Document Structure (0.0.3) ###
|
||||
|
||||
New in 0.0.3 the document now has a Structure member:
|
||||
The document now has a Structure member:
|
||||
|
||||
UglyToad.PdfPig.Structure structure = document.Structure;
|
||||
|
||||
@@ -241,6 +251,25 @@ This will return `false` if the document does not contain a form.
|
||||
|
||||
The fields can be accessed using the `AcroForm`'s `Fields` property. Since the form is defined at the document level this will return fields from all pages in the document. Fields are of the types defined by the enum `AcroFieldType`, for example `PushButton`, `Checkbox`, `Text`, etc.
|
||||
|
||||
### Hyperlinks (0.1.0) ###
|
||||
|
||||
A page has a method to extract hyperlinks (annotations of link type):
|
||||
|
||||
IReadOnlyList<UglyToad.PdfPig.Content.Hyperlink> hyperlinks = page.GetHyperlinks();
|
||||
|
||||
### TrueType (0.1.0) ###
|
||||
|
||||
The classes used to work with TrueType fonts in the PDF file are now available for public consumption. Given an input file:
|
||||
|
||||
using UglyToad.PdfPig.Fonts.TrueType;
|
||||
using UglyToad.PdfPig.Fonts.TrueType.Parser;
|
||||
|
||||
byte[] fontBytes = System.IO.File.ReadAllBytes(@"C:\font.ttf");
|
||||
TrueTypeDataBytes input = new TrueTypeDataBytes(fontBytes);
|
||||
TrueTypeFont font = TrueTypeFontParser.Parse(input);
|
||||
|
||||
The parsed font can then be inspected.
|
||||
|
||||
## Issues ##
|
||||
|
||||
At this stage the software is in Alpha. In order to proceed to Beta and production we need to see a wide variety of document types.
|
||||
|
||||
Reference in New Issue
Block a user