Class PdfDocument
The rendered PDF artifact.
public class PdfDocument
- Inheritance
-
PdfDocument
- Inherited Members
Constructors
PdfDocument(byte[])
public PdfDocument(byte[] data)
Parameters
databyte[]
Properties
BinaryData
public byte[] BinaryData { get; }
Property Value
- byte[]
Length
Size of the PDF in bytes.
public long Length { get; }
Property Value
PageCount
Number of pages in this PDF.
public int PageCount { get; }
Property Value
PeakRssBytes
Peak resident-set size, in bytes, observed across the WebKit render subprocess tree (python + WebProcess + NetworkProcess). Null when the renderer didn't emit metrics (e.g. running stub mode, or Docker without the metrics sidecar plumbed through the bind mount).
public long? PeakRssBytes { get; init; }
Property Value
- long?
PeakRssMb
Convenience: PeakRssBytes rounded to MB.
public double? PeakRssMb { get; }
Property Value
RenderMilliseconds
Wall-clock time the render subprocess took, in milliseconds. Includes page load, paint, PDF serialisation, and post-processing.
public long? RenderMilliseconds { get; init; }
Property Value
- long?
SteadyRssBytes
Steady-state resident-set size, in bytes, sampled after the render finished, all WebKit child processes have exited, GObject finalisers have run, and the glibc allocator has trimmed empty arenas back to the kernel.
This is the number to compare apples-to-apples against Chromium's Working Set on Windows — both reflect physical RAM occupied "right now", excluding transient peaks during page load + serialisation. For long-running pools, this is also what dictates whether you'll fit in your dyno's memory limit.
public long? SteadyRssBytes { get; init; }
Property Value
- long?
SteadyRssMb
Convenience: SteadyRssBytes rounded to MB.
public double? SteadyRssMb { get; }
Property Value
Methods
ExtractPage(int)
Extracts a single page (0-based) into a new PdfDocument, preserving its fonts, images and vector content.
public PdfDocument ExtractPage(int pageIndex)
Parameters
pageIndexint
Returns
ExtractPages(IEnumerable<int>)
Extracts an arbitrary set of pages (0-based; may be non-contiguous and in any order) into a new document.
public PdfDocument ExtractPages(IEnumerable<int> pageIndices)
Parameters
pageIndicesIEnumerable<int>
Returns
ExtractPages(int, int)
Extracts an inclusive range of pages (0-based) into a new document.
public PdfDocument ExtractPages(int startIndex, int endIndex)
Parameters
Returns
FromBytes(byte[])
Wraps existing PDF bytes for page operations.
public static PdfDocument FromBytes(byte[] data)
Parameters
databyte[]
Returns
FromFile(string)
Loads an existing PDF from disk (e.g. to split a file you didn't render).
public static PdfDocument FromFile(string path)
Parameters
pathstring
Returns
GetStream()
Returns a stream of the PDF data for attachments / HTTP responses.
public Stream GetStream()
Returns
Merge(params PdfDocument[])
Merges multiple PDFs into one, in order (the inverse of splitting).
public static PdfDocument Merge(params PdfDocument[] documents)
Parameters
documentsPdfDocument[]
Returns
SaveAs(string)
Saves the PDF to path and returns this instance for chaining.
public PdfDocument SaveAs(string path)
Parameters
pathstring
Returns
SaveAsAsync(string)
Asynchronously saves the PDF and returns this instance for chaining.
public Task<PdfDocument> SaveAsAsync(string path)
Parameters
pathstring
Returns
SplitIntoPages()
Splits this PDF into one single-page PdfDocument per page.
public IReadOnlyList<PdfDocument> SplitIntoPages()