Class PdfDocument
- Namespace
- CobaltPdf
- Assembly
- CobaltPdf.dll
The rendered PDF artifact. Use this to save the file or access raw binary data.
public class PdfDocument
- Inheritance
-
PdfDocument
- Inherited Members
Constructors
PdfDocument(byte[])
public PdfDocument(byte[] data)
Parameters
databyte[]
Exceptions
Properties
BinaryData
The raw PDF binary data.
public byte[] BinaryData { get; }
Property Value
- byte[]
Length
Returns the size of the PDF in bytes.
public long Length { get; }
Property Value
Methods
GetStream()
Returns a stream of the PDF data for email attachments or web responses.
public Stream GetStream()
Returns
SaveAs(string)
Saves the PDF document to the specified file path and returns this instance for chaining.
public PdfDocument SaveAs(string path)
Parameters
pathstringThe file path to write the PDF to.
Returns
- PdfDocument
This PdfDocument instance, allowing fluent chaining.
Examples
var pdf = await renderer
.WithLandscape()
.RenderUrlAsPdfAsync("https://example.com")
.SaveAs("output.pdf");
SaveAsAsync(string)
Asynchronously saves the PDF document to the specified file path and returns this instance for chaining.
public Task<PdfDocument> SaveAsAsync(string path)
Parameters
pathstringThe file path to write the PDF to.
Returns
- Task<PdfDocument>
A task that resolves to this PdfDocument instance, allowing fluent chaining.
Examples
var pdf = await (await renderer
.WithLandscape()
.RenderUrlAsPdfAsync("https://example.com"))
.SaveAsAsync("output.pdf");