mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-19 19:07:56 +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://dev.azure.com/pdfpig/pdfpig/_build/latest?definitionId=1&branchName=master)
|
||||||
[](https://codecov.io/gh/UglyToad/PdfPig)
|
[](https://codecov.io/gh/UglyToad/PdfPig)
|
||||||
[](https://gitter.im/pdfpig/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
[](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
|
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.
|
containing text and geometrical shapes.
|
||||||
|
|
||||||
This project aims to port [PDFBox](https://github.com/apache/pdfbox) to C#.
|
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 ##
|
## Get Started ##
|
||||||
|
|
||||||
The simplest usage at this stage is to open a document, reading the words from every page:
|
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();
|
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);
|
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.
|
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.
|
||||||
|
|
||||||
## 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).
|
|
||||||
|
|
||||||
## Usage ##
|
## 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" }))
|
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```:
|
The document contains the version of the PDF specification it complies with, accessed by ```document.Version```:
|
||||||
|
|
||||||
decimal version = 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:
|
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;
|
string title = document.Information.Title;
|
||||||
// etc...
|
// 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;
|
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.
|
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 ##
|
## 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.
|
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.
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
using Content;
|
using Content;
|
||||||
using Core;
|
using Core;
|
||||||
using Fonts;
|
using Fonts;
|
||||||
using Geometry;
|
|
||||||
using Graphics.Colors;
|
using Graphics.Colors;
|
||||||
using Graphics.Operations;
|
using Graphics.Operations;
|
||||||
using Graphics.Operations.General;
|
using Graphics.Operations.General;
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
<AssemblyVersion>0.1.0.0</AssemblyVersion>
|
<AssemblyVersion>0.1.0.0</AssemblyVersion>
|
||||||
<FileVersion>0.1.0.0</FileVersion>
|
<FileVersion>0.1.0.0</FileVersion>
|
||||||
<PackageIconUrl>https://raw.githubusercontent.com/UglyToad/PdfPig/master/documentation/pdfpig.png</PackageIconUrl>
|
<PackageIconUrl>https://raw.githubusercontent.com/UglyToad/PdfPig/master/documentation/pdfpig.png</PackageIconUrl>
|
||||||
|
<PackageIcon>pdfpig.png</PackageIcon>
|
||||||
<Product>PdfPig</Product>
|
<Product>PdfPig</Product>
|
||||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||||
@@ -42,6 +43,10 @@
|
|||||||
<ProjectReference Include="..\..\src\UglyToad.PdfPig\UglyToad.PdfPig.csproj" PrivateAssets="all" />
|
<ProjectReference Include="..\..\src\UglyToad.PdfPig\UglyToad.PdfPig.csproj" PrivateAssets="all" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="pdfpig.png" Pack="true" PackagePath="\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
|
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
|
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
|
||||||
|
BIN
tools/UglyToad.PdfPig.Package/pdfpig.png
Normal file
BIN
tools/UglyToad.PdfPig.Package/pdfpig.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
Reference in New Issue
Block a user