Fixed layout API

From
Jump to: navigation, search

Overview

Fixed layout API is a “classic” API that means that it’s designed to be very straightforward, being so close to the specification as possible. So almost every PDF entity, described by the spec, was mapped to a certain class from Fixed layout namespace.

This API was built around the FixedDocument class which in its turn represents the PDF document model. Anything that can be stored in PDF one can created using the Fixed layout API. The balance achieved between the binary low-level PDF model and smart higher level abstraction provided by this API unlocks the power of PDF to developers without compromising the quality of the final result. Unmatched flexibility makes this API a perfect choice for those who want to have total control over PDF processing.

Typical PDF generation pattern

The code below produces an empty PDF file:

// create output PDF file
using (FileStream outputStream = new FileStream("outfile.pdf", FileMode.Create, FileAccess.Write))
{
   FixedDocument document = new FixedDocument();
 
   // [fill doc here]

   // save to output stream
   document.Save(outputStream);
}
 

This code is pretty self-explaining. Just create a file, put some content into and save.

Document Level API

Both FixedDocument and FlowDocument contain properties which control the document viewing behavior in conforming PDF reader. It’s also possible to change document internal structure: swap pages, append new pages, add fields etc. Corresponding articles contain code samples with brief descriptions. In addition, the code demonstrating most of these techniques can be found in Samples folder of the product download package available on our website or in the samples repository.