Exporting Password Protected PDF Documents
The SaveSettings class in TX Text Control exports password-protected PDF documents with separate UserPassword and MasterPassword values. DocumentAccessPermissions controls granular access rights including printing levels, content extraction, editing, and document assembly.

With TX Text Control ships a sample application called TX Text Control Words. Amongst other things, TX Text Control Words illustrates how to export password protected PDF documents.
In the following paragraphs, I would like to explain in detail how password protected PDF documents are exported. I receive - on an almost daily basis - questions about this topic.
Using the TXTextControl.SaveSettings class, you can declare two passwords: the UserPassword to open the document and the MasterPassword for the document's access permissions. These permissions can be set using the SaveSettings.DocumentAccessPersmissions property.
Possible values are:
AllowAll
After the document has been opened no further document access is restricted.
AllowAuthoring
Allows comments to be added and interactive form fields (including signature fields) to be filled in.
AllowAuthoringFields
Allows existing interactive form fields (including signature fields) to be filled in.
AllowContentAccessibility
Allows content access for the visually impaired only.
AllowDocumentAssembly
Allows the document to be to assembled (insert, rotate or delete pages and create bookmarks or thumbnails).
AllowExtractContents
Allows text and/or graphics to be extraced.
AllowGeneralEditing
Allows the document contents to be modified.
AllowHighLevelPrinting
Allows the document to be printed.
AllowLowLevelPrinting
Allows the document to be printed (low-level).
The UserPassword must be entered, if the PDF is opened by the user. The MasterPassword must be entered, if the user is trying to change the permissions. The sample below shows how to export a PDF which allows low level printing. If the user would like to print the document in a higher level, the permissions must be changed and the password must be entered.
Dim saveSettings As New TXTextControl.SaveSettings
saveSettings.MasterPassword = "Master"
saveSettings.UserPassword = "User"
saveSettings.DocumentAccessPermissions =
TXTextControl.DocumentAccessPermissions.AllowLowLevelPrinting
TextControl1.Save(TXTextControl.StreamType.AdobePDF, saveSettings)Related Posts
Source Code to Send PDF As an E-mail Attachment
Sample code demonstrates how to export TX Text Control document content as a PDF file and send it as an email attachment. The downloadable source provides a complete working example of combining…
AI TokensASP.NET CoreDocument Conversion
Stop Burning Tokens to Convert your Documents
This article covers converting your source documents to Markdown on the way in and rendering the Markdown into a polished PDF on the way out. TX Text Control handles both conversions directly in…
AI Natural Language Document Generation with MCP and TX Text Control .NET
This article explains how AI agents can use natural language to create documents through an MCP server. Instead of letting a language model generate documents directly, the AI translates prompts…
C# Document Generation: A Developer's Guide for .NET
Document generation refers to the automatic creation of documents from application data. The success or complexity of a document generation workflow often depends on a single early architectural…
ASP.NETAccessibilityASP.NET Core
Validating PDF/UA Documents in .NET C#: A Practical Guide
This article explains how to validate PDF/UA documents in .NET C# using the TXTextControl.PDF.Validation NuGet package. It shows how to inspect validation status, generate JSON reports, handle…
