printpdf icon indicating copy to clipboard operation
printpdf copied to clipboard

`with_pages` documentation does not agree with implementation

Open Adamiomn opened this issue 8 months ago • 1 comments

PdfDocument in lib.rs has a method with_pages that states

/// Replaces document.pages with the new pages

However, the implementation uses append

    pub fn with_pages(&mut self, pages: Vec<PdfPage>) -> &mut Self {
        let mut pages = pages;
        self.pages.append(&mut pages);
        self
    }

Not sure what the intended behaviour is, both appending and replacing may be useful.

Adamiomn avatar May 17 '25 09:05 Adamiomn

Yeah, it should append the pages, so that you can do PdfDocument::new("title").with_pages(pages).save(options);

I think the pages field is public, so then you could just replace it yourself.

fschutt avatar May 17 '25 14:05 fschutt