Skip to content

Commit

Permalink
various
Browse files Browse the repository at this point in the history
  • Loading branch information
s3bk committed Dec 2, 2023
1 parent 3eb1258 commit dc5a911
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pdf/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ pub struct PdfBuilder<SC, OC, L> {
}
impl<SC, OC, L> PdfBuilder<SC, OC, L>
where
SC: Cache<Result<AnySync, Arc<PdfError>>>,
OC: Cache<Result<Arc<[u8]>, Arc<PdfError>>>,
SC: Cache<Result<AnySync, Arc<PdfError>>> + Default,
OC: Cache<Result<Arc<[u8]>, Arc<PdfError>>> + Default,
L: Log,
{
pub fn new(fileoptions: FileOptions<'_, SC, OC, L>) -> Self {
Expand Down
9 changes: 8 additions & 1 deletion pdf/src/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ impl Object for Content {
}
}

#[derive(Debug, DataSize, DeepClone)]
#[derive(Debug, DataSize, DeepClone, Clone)]
pub struct FormXObject {
pub stream: Stream<FormDict>,
}
Expand All @@ -539,6 +539,13 @@ impl Object for FormXObject {
})
}
}
impl ObjectWrite for FormXObject {
fn to_primitive(&self, update: &mut impl Updater) -> Result<Primitive> {
let mut stream = self.stream.to_pdf_stream(update)?;
stream.info.insert("Subtype", Name::from("Form"));
Ok(stream.into())
}
}

#[allow(clippy::float_cmp)] // TODO
pub fn serialize_ops(mut ops: &[Op]) -> Result<Vec<u8>> {
Expand Down
10 changes: 10 additions & 0 deletions pdf/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ impl<T> From<RcRef<T>> for Primitive {
Primitive::Reference(value.inner)
}
}
impl<T> From<RcRef<T>> for Ref<T> {
fn from(value: RcRef<T>) -> Self {
value.get_ref()
}
}

impl<T> RcRef<T> {
pub fn new(inner: PlainRef, data: Shared<T>) -> RcRef<T> {
Expand Down Expand Up @@ -387,6 +392,11 @@ impl<T> From<Shared<T>> for MaybeRef<T> {
MaybeRef::Direct(r)
}
}
impl<T> From<T> for MaybeRef<T> {
fn from(t: T) -> MaybeRef<T> {
MaybeRef::Direct(t.into())
}
}
impl<T> From<MaybeRef<T>> for Shared<T> {
fn from(r: MaybeRef<T>) -> Shared<T> {
match r {
Expand Down

0 comments on commit dc5a911

Please sign in to comment.