Skip to main content

Crate normordis_pdf

Crate normordis_pdf 

Source
Expand description

§normordis-pdf

Institutional PDF generation library for NORMAXIS mini-apps.

Generates professional PDF documents for Portuguese public administration, with support for:

  • Flow and Fixed Box layout modes
  • NORMAXIS Canonical Rich Text Format (NCRTF v1.1)
  • NORMAXIS Document Template format (NDT v1.3.0)
  • Named paragraph/table styles with inheritance (equivalent to Word Styles)
  • Tab stops (left, right, center, decimal) with leader characters
  • TTF/OTF font loading with real glyph metrics (rustybuzz + ttf-parser)
  • Left, Justify, Center, Right text alignment

§Quick Start

use normordis_pdf::{DocumentBuilder, Section, Paragraph, TextAlign};

let pdf = DocumentBuilder::new("Annual Report")
    .push(Section::new("1. Introduction", 1))
    .push(Paragraph::new("Document body text.").align(TextAlign::Justify))
    .render_to_bytes()?;

§Named Styles

use normordis_pdf::{DocumentBuilder, Paragraph, Section};

let pdf = DocumentBuilder::new("Styled Document")
    .push(Section::new("Introduction", 1))
    .push(Paragraph::new("Caption text.").style("caption"))
    .render_to_bytes()?;

§NDT Templates

use normordis_pdf::DocumentBuilder;

let data = r#"{"ndt_data":"1.0.0","data":{"entity":"Câmara Municipal"}}"#;
let template = r#"{"ndt":"1.0.0","body":[{"type":"paragraph","text":"{{entity}}"}]}"#;

let pdf = DocumentBuilder::new("Ofício")
    .push_ndt(template, data)?
    .render_to_bytes()?;

Re-exports§

pub use error::NormaxisPdfError;
pub use error::Result;
pub use signing::PreparedPdf;
pub use signing::SignatureConfig;
pub use signing::SignatureField;
pub use signing::SignatureOptions;
pub use signing::sign_pdf;
pub use styles::default_named_styles;
pub use styles::DocumentStyle;
pub use styles::NamedStyle;
pub use styles::Orientation;
pub use styles::PageSize;
pub use styles::ResolvedStyle;
pub use styles::RgbColor;
pub use styles::SecurityClassification;
pub use styles::StyleResolver;
pub use styles::TraceabilityMetadata;
pub use styles::Watermark;
pub use fonts::liberation_sans_family;
pub use fonts::liberation_serif_family;
pub use fonts::liberation_mono_family;
pub use fonts::FontData;
pub use fonts::FontFallbackChain;
pub use fonts::FontVariants;
pub use fonts::ShapedGlyph;
pub use fonts::FontFamily;
pub use fonts::FontVariant;
pub use fonts::FontRegistry;
pub use page::PageLayout;
pub use layout::AppliedStyle;
pub use layout::BorderStyle;
pub use layout::BoxBorder;
pub use layout::DecorationLine;
pub use layout::FixedBox;
pub use layout::GlyphUsageTracker;
pub use layout::HighlightColor;
pub use layout::KnuthPlassOptimizer;
pub use layout::LayoutResult;
pub use layout::LineBox;
pub use layout::LineBreakingMode;
pub use layout::LineSegment;
pub use layout::OpenTypeFeatures;
pub use layout::OverflowPolicy;
pub use layout::PageFlow;
pub use layout::TabStop;
pub use layout::TabStopAlign;
pub use layout::TextAlign;
pub use layout::TextDecoration;
pub use layout::TextLayoutEngine;
pub use layout::TextRun;
pub use layout::WordBox;
pub use builder::DocumentBuilder;
pub use builder::SigningBuilder;
pub use backend::FontRef;
pub use backend::ImageRef;
pub use backend::PdfBackend;
pub use backend::pdf_writer_backend::encode_for_identity_h;
pub use backend::pdf_writer_backend::generate_to_unicode_cmap;
pub use backend::pdf_writer_backend::subset_font;
pub use backend::pdf_writer_backend::to_cff_if_possible;
pub use document::CompressionLevel;
pub use document::Document;
pub use document::PdfStandard;
pub use elements::footnote::FootnoteMarkStyle;
pub use elements::footnote::FootnoteRef;
pub use elements::footnote::FOOTNOTE_SEPARATOR_THICKNESS_MM;
pub use elements::footer::PageFooter;
pub use elements::footer::SectionedFooter;
pub use elements::form::CheckBoxDef;
pub use elements::form::ComboBoxDef;
pub use elements::form::FieldRect;
pub use elements::form::FormField;
pub use elements::form::ListBoxDef;
pub use elements::form::RadioButtonDef;
pub use elements::form::TextFieldDef;
pub use elements::header::InstitutionalHeader;
pub use elements::header::SectionedHeader;
pub use elements::image::ImageElement;
pub use elements::list::BulletList;
pub use elements::list::CheckList;
pub use elements::list::CheckListItem;
pub use elements::list::ListItem;
pub use elements::list::ListItemElement;
pub use elements::list::OrderedList;
pub use elements::page_break::PageBreakElement;
pub use elements::paragraph::Paragraph;
pub use elements::paragraph::ParagraphBorder;
pub use elements::paragraph::ParagraphContent;
pub use elements::section::Section;
pub use elements::section_break::Orientation as SectionOrientation;
pub use elements::section_break::SectionBreak;
pub use elements::section_break::SectionMargins;
pub use elements::spacer::HorizontalRuleElement;
pub use elements::spacer::Spacer;
pub use elements::table::BorderLineStyle;
pub use elements::table::CellBorder;
pub use elements::table::CellBorders;
pub use elements::table::CellPadding;
pub use elements::table::RowHeight;
pub use elements::table::Table;
pub use elements::table::TableBuilder;
pub use elements::table::TableCell;
pub use elements::table::TableRow;
pub use elements::table::TableStyle;
pub use elements::toc::TableOfContents;
pub use elements::toc::TocEntry;
pub use elements::Element;
pub use elements::LayoutMode;
pub use elements::RenderContext;
pub use elements::RenderResult;
pub use elements::fixed::FixedImageBox;
pub use elements::fixed::FixedLineElement;
pub use elements::fixed::FixedTextBox;
pub use elements::fixed::ImageFit;
pub use elements::fixed::VerticalAlign;
pub use richtext::ncrtf_to_elements;
pub use richtext::parse_ncrtf;
pub use richtext::NcrtfDocument;
pub use template::parse_ndt;
pub use template::parse_ndt_data;
pub use template::render as render_ndt;
pub use template::serialize_ndt_json;
pub use template::serialize_ndt_toml;
pub use template::NdtDocument;
pub use template::TemplateError;
pub use template::ENGINE_NDT_DATA_VERSION;
pub use template::ENGINE_NDT_VERSION;
pub use template::resolve_runtime_fields;
pub use template::RuntimeContext;
pub use template::check_version_compatibility;
pub use template::model::NdtOutput;
pub use template::model::NdtSignature;
pub use template::model::NdtSignatureField;
pub use template::NdtRegistry;
pub use template::NdtTemplateRecord;
pub use template::NdtTemplateSummary;
pub use template::TemplateFilter;
pub use template::TemplateStatus;
pub use template::compile_ndt;
pub use template::parse_ndf;
pub use template::render_ndf;
pub use template::render_ndf_with_fonts;
pub use template::render_ndf_prepared_for_signing;
pub use template::render_ndf_prepared_for_signing_with_fonts;
pub use template::verify_ndf;
pub use template::CompileOptions;
pub use ndf::canonical_hash;
pub use ndf::Actor;
pub use ndf::AuditEvent;
pub use ndf::EventType;
pub use ndf::IntegrityFailure;
pub use ndf::IntegrityReport;
pub use ndf::NdfAudit;
pub use ndf::NdfDocument;
pub use ndf::NdfEmbeddedFont;
pub use ndf::NdfIntegrity;
pub use ndf::NdfMeta;
pub use ndf::NdfMetaNumbering;
pub use ndf::NdfOrigin;
pub use ndf::NdfOutput;
pub use ndf::NdfRevision;
pub use ndf::NdfRevisionRef;
pub use ndf::NdfSignature;
pub use ndf::NdfFilter;
pub use ndf::NdfRecord;
pub use ndf::NdfRecordStatus;
pub use ndf::NdfRecordSummary;
pub use ndf::NdfRegistry;
pub use richtext::marks::MarkValue as NcrtfMark;
pub use richtext::model::ImageBlock as NcrtfImage;
pub use compliance::ua::AccessibilityConfig;
pub use compliance::ua::ArtifactType;
pub use compliance::ua::StructEvent;
pub use compliance::ua::StructTag;
pub use compliance::ua::StructureTree;
pub use compliance::ua::UaError;
pub use compliance::ua::UaValidator;
pub use compliance::ua::UaWarning;

Modules§

backend
builder
compliance
document
elements
error
fonts
layout
ndf
page
richtext
signing
styles
template

Constants§

NCRTF_VERSION
NCRTF format version supported by this release.
NDF_VERSION
NDF format version produced by this release.
NDT_VERSION
NDT format version supported by this release.
PDF_BACKEND
PDF backend crate powering the output engine.
VERSION
Version of the normordis-pdf library.