Class PdfDocumentBuilder
Provides methods to construct new PDF documents.
public class PdfDocumentBuilder : IDisposable
- Inheritance
-
PdfDocumentBuilder
- Implements
- Inherited Members
Constructors
PdfDocumentBuilder()
Creates a document builder keeping resources in memory.
public PdfDocumentBuilder()
PdfDocumentBuilder(decimal)
Creates a document builder keeping resources in memory.
public PdfDocumentBuilder(decimal version)
Parameters
version
decimalPdf version to use in header.
PdfDocumentBuilder(Stream, bool, PdfWriterType, decimal, ITokenWriter)
Creates a document builder using the supplied stream.
public PdfDocumentBuilder(Stream stream, bool disposeStream = false, PdfWriterType type = PdfWriterType.Default, decimal version = 1.7, ITokenWriter tokenWriter = null)
Parameters
stream
StreamSteam to write pdf to.
disposeStream
boolIf stream should be disposed when builder is.
type
PdfWriterTypeType of pdf stream writer to use
version
decimalPdf version to use in header.
tokenWriter
ITokenWriterToken writer to use
Properties
ArchiveStandard
The standard of PDF/A compliance of the generated document. Defaults to None.
public PdfAStandard ArchiveStandard { get; set; }
Property Value
Bookmarks
The bookmark nodes to include in the document outline dictionary.
public Bookmarks Bookmarks { get; set; }
Property Value
DocumentInformation
The values of the fields to include in the document information dictionary.
public PdfDocumentBuilder.DocumentInformationBuilder DocumentInformation { get; set; }
Property Value
IncludeDocumentInformation
Whether to include the document information dictionary in the produced document.
public bool IncludeDocumentInformation { get; set; }
Property Value
Pages
The current page builders in the document and the corresponding 1 indexed page numbers. Use AddPage(double, double) or AddPage(PageSize, bool) to add a new page.
public IReadOnlyDictionary<int, PdfPageBuilder> Pages { get; }
Property Value
Methods
AddPage(double, double)
Add a new page with the specified size, this page will be included in the output when Build() is called.
public PdfPageBuilder AddPage(double width, double height)
Parameters
Returns
- PdfPageBuilder
A builder for editing the new page.
AddPage(PageSize, bool)
Add a new page with the specified size, this page will be included in the output when Build() is called.
public PdfPageBuilder AddPage(PageSize size, bool isPortrait = true)
Parameters
size
PageSizeThe size of the page to add.
isPortrait
boolWhether the page is in portait or landscape orientation.
Returns
- PdfPageBuilder
A builder for editing the new page.
AddPage(PdfDocument, int)
Add a new page with the specified size, this page will be included in the output when Build() is called.
public PdfPageBuilder AddPage(PdfDocument document, int pageNumber)
Parameters
document
PdfDocumentSource document.
pageNumber
intPage to copy.
Returns
- PdfPageBuilder
A builder for editing the page.
AddPage(PdfDocument, int, Func<PdfAction, PdfAction>)
Add a new page with the specified size, this page will be included in the output when Build() is called.
public PdfPageBuilder AddPage(PdfDocument document, int pageNumber, Func<PdfAction, PdfAction> copyLink)
Parameters
document
PdfDocumentSource document.
pageNumber
intPage to copy.
copyLink
Func<PdfAction, PdfAction>If set, links are copied based on the result of the delegate.
Returns
- PdfPageBuilder
A builder for editing the page.
AddStandard14Font(Standard14Font)
Adds one of the Standard 14 fonts which are included by default in PDF programs so that pages in this document can use it. These Standard 14 fonts are old and possibly obsolete.
public PdfDocumentBuilder.AddedFont AddStandard14Font(Standard14Font type)
Parameters
type
Standard14FontThe type of the Standard 14 font to use.
Returns
- PdfDocumentBuilder.AddedFont
An identifier which can be passed to AddText(string, decimal, PdfPoint, AddedFont).
AddTrueTypeFont(IReadOnlyList<byte>)
Adds a TrueType font to the builder so that pages in this document can use it.
public PdfDocumentBuilder.AddedFont AddTrueTypeFont(IReadOnlyList<byte> fontFileBytes)
Parameters
fontFileBytes
IReadOnlyList<byte>The bytes of a TrueType font.
Returns
- PdfDocumentBuilder.AddedFont
An identifier which can be passed to AddText(string, decimal, PdfPoint, AddedFont).
Build()
Builds a PDF document from the current content of this builder and its pages.
public byte[] Build()
Returns
- byte[]
The bytes of the resulting PDF document.
CanUseTrueTypeFont(IReadOnlyList<byte>, out IReadOnlyList<string>)
Determines whether the bytes of the TrueType font file provided can be used in a PDF document.
public bool CanUseTrueTypeFont(IReadOnlyList<byte> fontFileBytes, out IReadOnlyList<string> reasons)
Parameters
fontFileBytes
IReadOnlyList<byte>The bytes of a TrueType font file.
reasons
IReadOnlyList<string>Any reason messages explaining why the file can't be used, if applicable.
Returns
Dispose()
Disposes underlying stream if set to do so.
public void Dispose()