# Create a PDF

> Create PDF files from a Windows Forms TextControl: title and author in SaveSettings, a Save As dialog, PDF/A, user and master passwords and ServerTextControl.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Getting Started > PDF Processing > Create a PDF
- **2166 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/create/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/create/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/create/llms-full.txt

---

A document in the `TextControl` becomes a PDF with one call of `Save`, and `SaveSettings` adds what a PDF carries beyond its pages: a title and an author, a password, permissions, or PDF/A conformance for archiving. Starting from the editor of your first Windows Forms application, the steps below save the document as PDF in each of these ways and open the result in the default PDF reader.

### Prerequisites

- The application from [Create Your First Windows Forms Application](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-editor/first-application/llms-full.txt), with a `TextControl` named `textControl1` on `Form1`.
- The Professional or Enterprise edition. PDF/A is part of the Enterprise edition. See [Editions and Feature Availability](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/editions/llms-full.txt).

For each of the following sections, add a `Button` from the toolbox to the form and double-click it in the designer to create its `Click` handler. The code goes into *Form1.cs*, which needs these `using` directives:

```csharp
using System.Diagnostics;
using TXTextControl;
```

### Save the Document as PDF

The following handler saves the document of `textControl1` with a few document properties to *report.pdf* in the user's *Documents* folder and opens the file:

```csharp
private void createPdfButton_Click(object sender, EventArgs e)
{
    SaveSettings saveSettings = new SaveSettings()
    {
        Author = "Tim Typer",
        DocumentTitle = "Quarterly Report",
        DocumentSubject = "Finance",
        DocumentKeywords = new string[] { "report", "Q2", "finance" },
        CreatorApplication = "My Windows Forms Application",
        CreationDate = DateTime.Now,
        LastModificationDate = DateTime.Now
    };

    string path = Path.Combine(
        Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
        "report.pdf");

    textControl1.Save(path, StreamType.AdobePDF, saveSettings);

    // Open the PDF in the default PDF reader
    Process.Start(new ProcessStartInfo(path) { UseShellExecute = true });
}
```

The code works as follows:

- [SaveSettings](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/llms-full.txt) holds the options of a save. [Author](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/author-property/llms-full.txt), [DocumentTitle](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/documenttitle-property/llms-full.txt), [DocumentSubject](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/documentsubject-property/llms-full.txt), [DocumentKeywords](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/documentkeywords-property/llms-full.txt), [CreatorApplication](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/creatorapplication-property/llms-full.txt), [CreationDate](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/creationdate-property/llms-full.txt) and [LastModificationDate](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/lastmodificationdate-property/llms-full.txt) are saved in the document as its properties.
- [Save](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/save-method/llms-full.txt) writes the complete document. `StreamType.AdobePDF` is the PDF format, and an existing file is overwritten.
- `Process.Start` with `UseShellExecute` opens the file with the program Windows associates with PDF files.

Run the application, type some text and click the button. The PDF reader opens *report.pdf* with the text you typed.

Its document properties, which PDF readers show in their **Document Properties** dialog box, contain the title, author, subject and keywords of the `SaveSettings`:

![The Document Properties dialog box of Adobe Acrobat for a PDF created with TX Text Control, showing its title, author, subject, keywords, creation and modification dates and the application.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/pdf-document-properties.6bed9dcb.webp)

### Let the User Choose the File

Called with a `StreamType` and no file name, `Save` opens the **Save As** dialog box with the filter of that format, and [SaveSettings.SavedFile](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/savedfile-property/llms-full.txt) then contains the file the user chose. [Load and Save Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-editor/load-save/#add-new-open-save-and-save-as) builds **Save As** this way. A further overload adds options to the dialog box, such as a button to enter a PDF password. See [Supported File Formats](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/file-formats/#open-and-save-as-dialog-boxes).

### Create a PDF/A Document

PDF/A is the standard for long-term archiving, and TX Text Control saves it as PDF/A-3a with `StreamType.AdobePDFA`. A PDF/A document embeds its fonts, so the document should use only fonts that can be embedded:

```csharp
private void createPdfAButton_Click(object sender, EventArgs e)
{
    // Use only fonts that can be embedded in the PDF
    textControl1.FontSettings.EmbeddableFontsOnly = true;

    textControl1.Save("archive.pdf", StreamType.AdobePDFA);
}
```

[FontSettings.EmbeddableFontsOnly](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/fontsettings/embeddablefontsonly-property/llms-full.txt) restricts the document to embeddable fonts. PDF/A does not allow encryption, so a PDF/A document has no password. See [PDF/A](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/pdf/pdf-a/llms-full.txt).

### Protect the PDF With Passwords

A PDF can have two passwords: the user password is needed to open the document, and the master password protects its permissions, such as printing or copying text.

```csharp
private void protectedPdfButton_Click(object sender, EventArgs e)
{
    SaveSettings saveSettings = new SaveSettings()
    {
        UserPassword = "user1234",
        MasterPassword = "owner1234",
        DocumentAccessPermissions = DocumentAccessPermissions.AllowLowLevelPrinting |
                                    DocumentAccessPermissions.AllowExtractContents
    };

    textControl1.Save("protected.pdf", StreamType.AdobePDF, saveSettings);
}
```

- [UserPassword](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsavesettingsbase/userpassword-property/llms-full.txt) and [MasterPassword](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsavesettingsbase/masterpassword-property/llms-full.txt) set the two passwords.
- [DocumentAccessPermissions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/savesettings/documentaccesspermissions-property/llms-full.txt) sets what users may do without the master password. The values are combined with `|`, and they take effect only when a master password is set.

When the file is opened, the PDF reader asks for the user password:

![The Password dialog box of a PDF reader, stating that the file is protected and asking for the Document Open Password.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/pdf-open-password-prompt.f829ccbf.webp)

PDF readers enforce the permissions, but they are no protection against every program. See [Passwords and Access Permissions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/pdf/passwords/llms-full.txt).

### Create a PDF Without the Editor

To convert a document the user does not see, use a `ServerTextControl`, which has the same `Load` and `Save` methods and takes the same `SaveSettings`. [Convert a File Without the Editor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-processing/save-docx-pdf/#convert-a-file-without-the-editor) shows the code.

### Next Steps

- [Create a PDF Form](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/form/llms-full.txt): add fillable form fields to the PDF.
- [Digitally Sign a PDF](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/sign/llms-full.txt): sign the PDF with a certificate.
- [PDF Processing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/pdf/llms-full.txt): PDF creation, import, fonts, attachments and metadata in detail.
- The blog article [PDF Security Explained: Passwords, Permissions, Encryption, and Digital Signatures in C# .NET](https://www.textcontrol.com/blog/2026/06/08/pdf-security-explained-passwords-permissions-encryption-and-digital-signatures-in-csharp-dotnet/): what passwords and permissions protect.

---

## Nearby

- **Previous:** [PDF Processing](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/llms-full.txt)
- **Next:** [Create a PDF Form](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/pdf/form/llms-full.txt)
