Back to Devexpress

PdfDocumentProcessor.CreateEmptyDocument(Stream) Method

officefileapi-devexpress-dot-pdf-dot-pdfdocumentprocessor-dot-createemptydocument-x28-system-dot-io-dot-stream-x29.md

latest5.0 KB
Original Source

PdfDocumentProcessor.CreateEmptyDocument(Stream) Method

Creates an empty PDF document with no pages and writes it to a stream.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Docs.v25.2.dll

NuGet Package : DevExpress.Document.Processor

Declaration

csharp
public void CreateEmptyDocument(
    Stream stream
)
vb
Public Sub CreateEmptyDocument(
    stream As Stream
)

Parameters

NameTypeDescription
streamStream

A Stream class descendant specifying the stream to which the PDF empty document should be written.

|

Remarks

Use this method to create an empty document and write it to a stream.

Use the PDF document creation API to continue to generate the document layout (e.g., append pages with graphics to the PDF document, generate bookmarks, and attach files). Refer to the following topic for more information: Additional Content

Note

When all operations with a created document are completed, you need to close the document. Call the PdfDocumentProcessor.CloseDocument method or dispose of the PdfDocumentProcessor instance.

The PDF specification does not describe empty documents. For this reason, most third-party PDF viewers cannot open such files. This does not apply to the DevExpress WinForms PDF Viewer and WPF PDF Viewer, which are less demanding concerning the validity of opened documents, and are capable of opening documents containing no pages.

This CreateEmptyDocument method overload writes generated document content into the stream specified as this method’s parameter. The SaveDocument method call rewrites this stream.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateEmptyDocument(Stream) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

asp-net-core-dashboard-export-all-items/CS/AspNetCoreDashboard_ExportAllItems/Controllers/ExportController.cs#L25

csharp
using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor()) {
    documentProcessor.CreateEmptyDocument(resultStream);
    for (int i = 0; i < dashboard.Items.Count; i++) {

web-forms-dashboard-pdf-export-with-filter-values-on-different-pages/CS/ASPxDashboard_ServerExport/Default.aspx.cs#L26

csharp
using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor()) {
    documentProcessor.CreateEmptyDocument(resultStream);
    for (int i = 0; i < parameters.Length; i++) {

office-file-api-in-web-api-app/CS/Controllers/PdfController.cs#L18

csharp
using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {
    processor.CreateEmptyDocument(result);
    foreach (var file in files) {

web-forms-dashboard-pdf-export-with-filter-values-on-different-pages/VB/ASPxDashboard_ServerExport/Default.aspx.vb#L26

vb
Using documentProcessor As New PdfDocumentProcessor()
    documentProcessor.CreateEmptyDocument(resultStream)
    For i As Integer = 0 To parameters.Length - 1

See Also

PdfDocumentProcessor Class

PdfDocumentProcessor Members

DevExpress.Pdf Namespace