PrinterLayoutDocument¶
Namespace: ThinkGeo.Core
A printer layout ready to be written out: one or more pages, each with its own sheet and its own layout layers.
public class PrinterLayoutDocument
Inheritance object → PrinterLayoutDocument
Remarks:
This is the entry point for producing output from a layout. It opens and closes each layer and draws them in order, so callers do not have to know that the sheet is normally left out of the output. PrinterLayoutDocument.ExportPdfAsync(Stream, CancellationToken) writes every page into one PDF, each page the size of its own sheet; PrinterLayoutDocument.DrawAsync(GeoCanvas) draws a one-page document on a canvas the caller started - a printer, an image, a PDF set up by hand.
var document = new PrinterLayoutDocument();
foreach (var cell in mapBookGrid) document.Pages.Add(BuildPage(cell));
using (var stream = File.Create("atlas.pdf"))
{
await document.ExportPdfAsync(stream);
}
Properties¶
Pages¶
Gets the pages, in the order they are written.
public Collection<PrinterLayoutPage> Pages { get; }
Property Value¶
IncludePageBackground¶
Gets or sets whether each page's sheet is drawn into the output. Defaults to false.
public bool IncludePageBackground { get; set; }
Property Value¶
Remarks:
The sheet carries the white fill and border that make the page visible while it is being composed on screen. Printing or exporting it would put that border on the paper, so it is left out unless you ask for it.
Constructors¶
PrinterLayoutDocument()¶
public PrinterLayoutDocument()
Methods¶
DrawAsync(GeoCanvas)¶
Draws the layout's page onto the canvas.
public Task DrawAsync(GeoCanvas canvas)
Parameters¶
canvas GeoCanvas
A canvas that has already been started with BeginDrawing. Its
cancels the draw, the layers' opening included.
Returns¶
Exceptions¶
InvalidOperationException
The document has more than one page.
Remarks:
A canvas is one page. A document of several pages is written with PrinterLayoutDocument.ExportPdfAsync(Stream, CancellationToken), which gives each page a page of its own.
ExportPdfAsync(Stream, CancellationToken)¶
Writes every page of the layout into one PDF, each page the size of its own sheet.
public Task ExportPdfAsync(Stream stream, CancellationToken cancellationToken)
Parameters¶
stream Stream
A writable stream that receives the PDF. It is left open.
cancellationToken CancellationToken
Cancels the export between layers and inside them, the way a map draw is cancelled; the
pages already written stay in a finished document.
Returns¶
Exceptions¶
The document has no pages, or a page's sheet has no size.
OperationCanceledException
The export was cancelled.
Remarks:
The PDF is finished even when a page fails to draw or the export is cancelled, so the stream is never left holding half a document that would be written into it later.