Core Concepts
Fundamental Entities
Section titled “Fundamental Entities”There are several fundamental entities that provide the working structure of AstraDoc:
Projects
Section titled “Projects”Projects form the basis for grouping related resources together. Projects often mean different things to different businesses, but you can understand them as a way to group documents, styles, components and assets for a customer or a customer’s projects. Documents, Styles and Components all require a link to a project, Assets do not and can be created without an associated project, allowing them to be used across many projects.
Documents
Section titled “Documents”Documents are the templates from which your PDF files will be generated. Documents are created using the visual designer and will consist of pages containing content elements (such as text or images) and layout elements (such as sections or rows) along with components, styles, assets and the use of templating syntax to form the final template used to render out PDFs.
Styles
Section titled “Styles”Styles are applied to documents in order to provide a global means of controlling the look and feel of the final PDF within a project. Styles are created using the provided style editor and attached to a document using the document’s visual designer. Multiple styles may be applied to a document, but, in instances where 2 styles apply to the same property, the style added last will override styles added previously.
In AstraDoc, there are multiple styles types that behave differently to one another and form part of a strict hierarchy.
- Attribute Styles: These are style properties that apply to any element that contains the property in the document. Attribute styles are a good mechanism for ensuring a particular style should apply to every element by default e.g. font family.
- Element Styles: These are properties that only apply to a certain element, for example, ensuring all image elements in the document contain a certain border style, or all number elements have a set digit grouping style. Element styles will override attribute styles when both styles apply to the same property on an element.
- Class Styles: Class styles are similar to CSS classes. They are named style property sets and can be attached to an element using its Style Class property in the visual designer. Class styles will override both element and attribute style types. You can attach multiple style classes to an element by supplying a space delimited list of class names (Class Style names cannot contain spaces). In cases where 2 class styles apply to the same property, the style class added last will override the preceding class.
- Element Attributes: Style attributes that are applied directly to the element using the properties panel in the visual designer have the highest precedence and will override all other style types that may be applied to the element.
Components
Section titled “Components”Components enable the reusability of renderable content within a document. Components are designed in the visual designer (similar to documents), except they cannot have styles attached to them and their size is dictated by their content, rather than a specified width & height. When dropped into a document, properties added to the component instance are transformed into a JSON payload which is then sent into the component during document rendering. This allows components to render dynamic data.
An important concept to understand with components is that they take on the form of their root element (which is restricted to layout elements). This means that a component with a column as its root element, becomes a column component and can therefore only be dropped into row elements. Likewise, components with a section or a row element at its root, become section and row components respectively. Components cannot have content elements as a root element.
Assets
Section titled “Assets”Assets allow you to add PNG and JPEG images to your documents through the Image element. They also allow you to assign custom fonts to text based elements. Assets can be managed either via the Assets page in the app or, if a more dynamic approach is needed, via the Assets API provided by AstraDoc. Unlike documents, styles and components, assets do not need to be linked to a project, allowing them to be used within components and documents linked to any project.