# Create Document

Learn more about PrintDocument from this WinForms documentation helpfile.

## Content

The **C1PrintDocument** class supports two different approaches to create documents: **Generate** method and **StartDoc**-**EndDoc** method. The following sections describe each method and highlight their implementation differences.

## Generate Method

The [Generate](/componentone/api/win/online-printdocument/dotnet-api/C1.PrintDocument.10/C1.C1Preview.C1PrintDocument.Generate.html) method of the [C1PrintDocument](/componentone/api/win/online-printdocument/dotnet-api/C1.PrintDocument.10/C1.C1Preview.C1PrintDocument.html) class allows for seamless document generation. This method is used when the render objects are added directly into the body of the document as illustrated in the code below:

```csharp
this.c1PrintDocument1.Body.Children.Add(new RenderText("Hello, World!"));
this.c1PrintDocument1.Generate();
```

Optionally, you can also use the [RefreshModeEnum.RefreshCalculatedValues](/componentone/api/win/online-printdocument/dotnet-api/C1.PrintDocument.10/C1.C1Preview.RefreshModeEnum.html) refresh mode to update data-bound and calculated values while generating the document.

## StartDoc - EndDoc Method

**StartDoc** method initiates document generation while **EndDoc** method marks its end. To add objects to the document block, StartDoc uses available methods such as RenderBlock, RenderDirect, or RenderInline. For more information on rendering objects, see RenderObjects topic. The GIF below shows a document created using StartDoc and EndDoc method:

![StartDoc() and EndDoc()](https://cdn.mescius.io/document-site-files/images/6772f728-508e-4e80-9394-208f07d64beb/images/printdocument-startdoc.gif)
The following code illustrates the StartDoc and EndDoc methods to create document:

```csharp
RenderText txt1 = new RenderText();
txt1.Text = "This is a render text sample";
c1PrintDocument1.StartDoc();
c1PrintDocument1.RenderBlock(txt1);
c1PrintDocument1.EndDoc();
```

>type=note
> Note: The **StartDoc-EndDoc** and the **Generate** methods cannot be used together. Once the StartDoc method is called, the document generation has already begun; hence, one cannot make a call to refresh or regenerate the document in between by using the Generate method.

## Page Break

The C1PrintDocument class provides two ways to insert a new page or page break: [NewPage](/componentone/docs/win/online-printdocument/) method and [BreakEnum](/componentone/docs/win/online-printdocument/) enumeration.

### NewPage method

The **NewPage** method of **C1PrintDocument class** is used with StartDoc and EndDoc methods to insert a new page into the document. The GIF below demonstrates the **NewPage** method to add a new page to the document

![Adding NewPage gif](https://cdn.mescius.io/document-site-files/images/6772f728-508e-4e80-9394-208f07d64beb/images/printdocument-newpage.gif)

The following code snippet illustrates the NewPage method to insert a new page in the document.

```csharp
RenderText txt1 = new RenderText();
txt1.Text = "This is line 1";
RenderText txt2 = new RenderText();
txt2.Text = "This is line 2";
c1PrintDocument1.StartDoc();
c1PrintDocument1.RenderBlock(txt1);
c1PrintDocument1.AllowNonReflowableDocs = true;
c1PrintDocument1.NewPage();
c1PrintDocument1.RenderBlock(txt2);
c1PrintDocument1.EndDoc();
```

>type=note
> **Note**: To use the NewPage method, set [AllowNonReflowableDocs](/componentone/docs/win/online-printdocument/) property of C1PrintDocument class to true.

### BreakEnum

When the **Generate** method is used, you can add a page break before or after a render object using the **BreakEnum** enumeration. The GIF below demonstrates the use of **BreakEnum** to insert a page break after text in the Page 1:

![Adding NewPage breakenum gif](https://cdn.mescius.io/document-site-files/images/6772f728-508e-4e80-9394-208f07d64beb/images/printdocument-breakenum.gif)

The below code illustrates use of BreakEnum to insert page break in the document:

```csharp
c1PrintDocument1.Body.Children.Add(txt1);
c1PrintDocument1.Body.Children.Add(txt2);
txt1.BreakAfter = BreakEnum.Page;
this.c1PrintDocument1.Generate();
```