lo_writer 0.3.1

Writer-like document editing with Markdown and plain text import/export
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! PDF export for `TextDocument` using the shared `lo_core::pdf` writer.

use lo_core::{units::Length, write_text_pdf, TextDocument};

/// Default page is A4 in points (595×842pt).
pub fn to_pdf(document: &TextDocument) -> Vec<u8> {
    to_pdf_with_size(document, Length::pt(595.0), Length::pt(842.0))
}

pub fn to_pdf_with_size(document: &TextDocument, width: Length, height: Length) -> Vec<u8> {
    let lines: Vec<String> = document
        .plain_text()
        .lines()
        .map(|s| s.to_string())
        .collect();
    write_text_pdf(&lines, width, height)
}