Skip to content

Commit d81f7fc

Browse files
committed
Add documentation
1 parent 655d2d0 commit d81f7fc

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/lib.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,25 @@ impl Pdf {
307307
finish_trailer(buf, xref_offset, &[b'\n'])
308308
}
309309

310-
/// TODO
310+
/// Write the cross-reference stream and file trailer and return the
311+
/// underlying buffer. This method is functionally the same as [`Pdf::finish`],
312+
/// the difference being that the cross-reference information is written as a
313+
/// cross-reference stream instead of a cross-reference table. Cross-reference stream
314+
/// usually allow for smaller file sizes since they can also be compressed (see below),
315+
/// but are only available from PDF 1.5 onwards. It is also necessary to call
316+
/// this method instead of [`Pdf::finish`] in case object stream are used anywhere
317+
/// in the document.
318+
///
319+
/// `xref_id` will be the object identifier used for the cross-reference stream. As in other
320+
/// cases, the identifier needs to be unique throughout the whole document.
321+
///
322+
/// In addition to that, you can optionally pass a closure to the `hook` parameter: The
323+
/// input of the closure will be the raw content of the xref stream, and the output should be
324+
/// the filtered as well as a single filter or a lists of filter that need to be applied to
325+
/// unfilter the data. In case you don't want to apply additional compression, you can simply
326+
/// pass `None` to the closure.
327+
///
328+
/// Panics if any indirect reference id was used twice.
311329
pub fn finish_with_xref_stream(
312330
self,
313331
xref_id: Ref,

0 commit comments

Comments
 (0)