PeachDrawing.PDF

PdfPageSource Class

An existing PDF opened so its pages can be painted onto any Canvas: a PdfCanvas to stamp a page of it over or under a document being written, a raster canvas to render it.

public sealed class PdfPageSource

Inheritance System.Object → PdfPageSource

Remarks

Painting re-draws the page’s content rather than copying the file’s objects, so it works the same on every canvas. On a PdfCanvas the text, paths, clips, color and alpha come out as ordinary content of the new document, with fonts re-embedded and text keeping the text map of the original.

What the importer cannot draw yet (fonts without an embedded TrueType, OpenType, CFF or Type 1 program) is skipped, and Paint(int, Canvas) names each such feature in its result. A file protected with AES is read, with its password when it needs one; one that uses RC4 (which .NET does not provide) is refused.

Properties  
PageCount The number of pages in the file.
Methods  
CreateTagSession(PdfTagRecorder) Starts the tagging of one drawing of a page of this file onto a document being tagged. Pass the result to Paint(int, Canvas, PdfAnnotationPaint, PdfTagSession), and to TieLinkToStructure(PdfTagSession, PdfSourceLink, PdfLink) for the links of the page; use a new one each time a page is drawn, so each drawing gets structure elements of its own.
GetAnnotations(int, double) The annotations of a page that are neither links nor form fields (highlights, notes, stamps, drawings...) and have an appearance, ready to add to a page of a document with AddAnnotation(PdfComposerPage, PdfAnnotationDefinition). Each is drawn by the appearance stream it had in the file. An annotation with no appearance stream, one marked hidden, and pop-up windows have no definition here.
GetAttachments() The files attached to the PDF.
GetConformance() The PDF/A and PDF/X levels the file claims for itself.
GetFormFields(int, double, Func<string,string>) The interactive form fields (text fields, check boxes, radio buttons and choice fields) with widgets on a page, ready to add to a page of a document with AddField(PdfComposerPage, PdfFormFieldDefinition). Each field is drawn by the appearance stream of its own widget, so it looks as it did in the file; a push button or signature field has no definition here and is drawn by Paint(int, Canvas, PdfAnnotationPaint, PdfTagSession) with ExceptFormFields instead.
GetLinks(int) The links of a page that open a web address or lead to another place in the file; other kinds of link are left out.
GetMetadata() The title, author and the other document information of the file.
GetNamedDestinations() The destinations the file gives a name, which another document can link to.
GetOutline() The document outline (the bookmarks sidebar of a reader) flattened in reading order; an entry’s PageIndex is a page of this file.
GetOutputIntent() The file’s output intent, the condition its colors are meant for, when it has one with a readable ICC profile.
GetPageSize(int) The size of a page as a viewer shows it (after its rotation), in points.
Open(byte[]) Opens a PDF held in memory.
Open(byte[], string) Opens a PDF held in memory that is protected with a password.
Open(Stream) Opens a PDF read from stream, which is read to the end and not closed.
Open(Stream, string) Opens a PDF protected with a password, read from stream, which is read to the end and not closed.
Paint(int, Canvas) Paints a page onto canvas, whose origin is the top-left of the area the page is to occupy and whose units are points. The page is clipped to its own box, so content never spills beyond it.
Paint(int, Canvas, PdfAnnotationPaint, PdfTagSession) Paints a page like Paint(int, Canvas) and then the appearance of its annotations, as a viewer shows them (a highlight, a stamp, a note, a drawing, a filled-in field).
TieLinkToStructure(PdfTagSession, PdfSourceLink, PdfLink) Ties a link that was added to a document to the structure element the file gave the link, when that element was recorded by tags, so a reader can reach one from the other. Call it after Finish(). Does nothing for a link whose file had no structure for it.
TryGetCustomString(int, string, string, string) Tries to read a custom string entry from a dictionary associated with a page.