Creating PDF files is often a tricky task in business applications. There are many ways to create PDF documents in VB.NET or C# such as PDF printer drivers or PDF libraries to position elements on a page, but in most cases, you still have to take care of paging and more complex tasks such as widow and orphan control.

Using TX Text Control, you can create documents from scratch programmatically using a fully-featured API or use pre-designed MS Word compatible templates. TX Text Control is automatically taking care of page sizes, paging, margins, headers and footers and section breaks. All of these features can be completely controlled to create pixel-perfect documents in many industry-standard formats such as DOC, DOCX, RTF and Adobe PDF or PDF/A.

MailMerge MS Word Compatible Templates

TX Text Control provides a powerful mail merge engine to populate placeholder fields with data from various data sources such as JSON, XML and IEnumerable objects. Text Control reporting combines powerful word processing with high-end reporting features like master-detail repeating blocks, charts, barcodes and many more. Essentially, an MS Word compatible template is loaded, data is merged and the resulting document can be exported to Adobe PDF.

Password Protect Your Adobe PDF Documents

Using the TXTextControl.SaveSettings class TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
SaveSettings Class
The SaveSettings class provides properties for advanced settings and information during save operations.
, you can define 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.DocumentAccessPermissions 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.

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.

SaveSettings saveSettings = new SaveSettings()
{
MasterPassword = "Master",
UserPassword = "User",
DocumentAccessPermissions =
DocumentAccessPermissions.AllowLowLevelPrinting |
DocumentAccessPermissions.AllowExtractContents
};
textControl1.Save(StreamType.AdobePDF, saveSettings);
view raw data.cs hosted with ❤ by GitHub

Export Adobe PDF/A

A PDF/A document must be 100% self-contained. That implies that all information that is required to render the PDF must be embedded. That includes all used fonts of the document. TX Text Control provides a special PDF/A edit mode, so that users are only able to pick the supported fonts from the drop down box in the ribbon bar. Not every font can be embedded using PDF/A for a couple of reasons: The license of the font forbids embedding or a device dependent font is used. TX Text Control is able to substitute unsupported fonts automatically and it provides an event where you can replace the fonts based on your own logic. Only this way guarantees a smooth export to this special Adobe PDF format.

Exporting to PDF/A is as easy as exporting to any other supported format and can be achieved with one line of code calling the TXTextControl.TextControl.Save method TX Text Control .NET for Windows Forms
TXTextControl Namespace
TextControl Class
Save Method
Saves the complete contents of a document with the specified format.
.

Digitally Sign Adobe PDF Documents

TX Text Control can be efficiently used to create Adobe PDF documents with digital signatures. These signatures can be created with PFX, DER Cer or Base64 CER certificate files. All you need is a valid certificate that is defined in the TXTextControl.SaveSettings class TX Text Control .NET for Windows Forms
TXTextControl Namespace
SaveSettings Class
The SaveSettings class provides properties for advanced settings and information during save operations.
.

TXTextControl.SaveSettings settings = new TXTextControl.SaveSettings();
X509Certificate2 cert = new X509Certificate2("test.pfx", "123");
settings.DigitalSignature = new TXTextControl.DigitalSignature(cert, null);
textControl1.Save("results.pdf", TXTextControl.StreamType.AdobePDF, settings);
view raw data.cs hosted with ❤ by GitHub

Import PDF Document

TX Text Control is able to import "digitally born" PDF documents, so that you can view, edit or convert these files. A main advantage of TX Text Control is that it is fully programmable. The PDF document is imported and can be modified just like any other format such as DOC or DOCX. The fully featured API can be used to change the content or to search on the document.

Using this approach, you can open PDF documents to search for strings in document pages.

Import Form Fields from PDF Documents

Interactive forms in the Adobe PDF format are also known as AcroForm - the de-facto standard for PDF forms processing. Internally, the forms structure of a PDF document can be imported using the Adobe PDF import functionality of TX Text Control.

We published a GitHub project that shows how to process the output of the PDF import process using an extension in the DocumentServer namespace.

The following code loops through all elements in order to read the options of contained combo boxes:

AcroForm[] listAcroForms = TXTextControl.DocumentServer.Forms.PDF.ImportForms("form.pdf");
foreach (AcroForm formElement in listAcroForms)
{
if(formElement.GetType() == typeof(AcroFormComboBox))
{
string[] saOptions = ((AcroFormComboBox)formElement).Options;
}
}
view raw data.cs hosted with ❤ by GitHub

Summary and Conclusion

TX Text Control provides a feature-complete set of tools to create, modify and to edit Adobe PDF documents. Download a trial version for your platform today:

Product Overview