diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-12-02 13:37:33 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-12-04 10:12:07 +0100 |
| commit | f8f2ba6a5f8c8ca7dbb85cf17b73332a0c301c60 (patch) | |
| tree | b3bc754509fb3ab4c74493848fe96f116b7907ed /crates/typst-pdf | |
| parent | 76c24ee6e35715cd14bb892d7b6b8d775c680bf7 (diff) | |
Rename `Document` to `PagedDocument`
Diffstat (limited to 'crates/typst-pdf')
| -rw-r--r-- | crates/typst-pdf/src/lib.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/crates/typst-pdf/src/lib.rs b/crates/typst-pdf/src/lib.rs index efc99b74..f9b4e902 100644 --- a/crates/typst-pdf/src/lib.rs +++ b/crates/typst-pdf/src/lib.rs @@ -24,8 +24,7 @@ use pdf_writer::{Chunk, Name, Pdf, Ref, Str, TextStr}; use serde::{Deserialize, Serialize}; use typst_library::diag::{bail, SourceResult, StrResult}; use typst_library::foundations::{Datetime, Smart}; -use typst_library::layout::{Abs, Em, PageRanges, Transform}; -use typst_library::model::Document; +use typst_library::layout::{Abs, Em, PageRanges, PagedDocument, Transform}; use typst_library::text::Font; use typst_library::visualize::Image; use typst_syntax::Span; @@ -49,7 +48,7 @@ use crate::resources::{ /// /// Returns the raw bytes making up the PDF file. #[typst_macros::time(name = "pdf")] -pub fn pdf(document: &Document, options: &PdfOptions) -> SourceResult<Vec<u8>> { +pub fn pdf(document: &PagedDocument, options: &PdfOptions) -> SourceResult<Vec<u8>> { PdfBuilder::new(document, options) .phase(|builder| builder.run(traverse_pages))? .phase(|builder| { @@ -176,7 +175,7 @@ struct PdfBuilder<S> { /// this phase. struct WithDocument<'a> { /// The Typst document that is exported. - document: &'a Document, + document: &'a PagedDocument, /// Settings for PDF export. options: &'a PdfOptions<'a>, } @@ -186,7 +185,7 @@ struct WithDocument<'a> { /// /// This phase allocates some global references. struct WithResources<'a> { - document: &'a Document, + document: &'a PagedDocument, options: &'a PdfOptions<'a>, /// The content of the pages encoded as PDF content streams. /// @@ -235,7 +234,7 @@ impl<'a> From<(WithDocument<'a>, (Vec<Option<EncodedPage>>, Resources<()>))> /// We are now writing objects corresponding to resources, and giving them references, /// that will be collected in [`References`]. struct WithGlobalRefs<'a> { - document: &'a Document, + document: &'a PagedDocument, options: &'a PdfOptions<'a>, pages: Vec<Option<EncodedPage>>, /// Resources are the same as in previous phases, but each dictionary now has a reference. @@ -278,7 +277,7 @@ struct References { /// tree is going to be written, and given a reference. It is also at this point that /// the page contents is actually written. struct WithRefs<'a> { - document: &'a Document, + document: &'a PagedDocument, options: &'a PdfOptions<'a>, globals: GlobalRefs, pages: Vec<Option<EncodedPage>>, @@ -304,7 +303,7 @@ impl<'a> From<(WithGlobalRefs<'a>, References)> for WithRefs<'a> { /// /// Each sub-resource gets its own isolated resource dictionary. struct WithEverything<'a> { - document: &'a Document, + document: &'a PagedDocument, options: &'a PdfOptions<'a>, globals: GlobalRefs, pages: Vec<Option<EncodedPage>>, @@ -336,7 +335,7 @@ impl<'a> From<(WithRefs<'a>, Ref)> for WithEverything<'a> { impl<'a> PdfBuilder<WithDocument<'a>> { /// Start building a PDF for a Typst document. - fn new(document: &'a Document, options: &'a PdfOptions<'a>) -> Self { + fn new(document: &'a PagedDocument, options: &'a PdfOptions<'a>) -> Self { Self { alloc: Ref::new(1), pdf: Pdf::new(), |
