Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // example.rs
- fn main() {
- let doc = pdfdoc::PDFDoc::new("examples/data/LargeTest_0000001.pdf").unwrap();
- doc.merge_xfdf_and_redact("examples/data/LargeTest_0000001.xfdf");
- println!("merged");
- }
- // pdfdoc.rs
- pub struct PDFDoc {
- doc: ffi::TRN_PDFDoc,
- }
- impl PDFDoc {
- ...
- pub fn merge_xfdf_and_redact(self, xfdf: &str) -> Self {
- let mut fdf: ffi::TRN_FDFDoc = std::ptr::null_mut();
- let xfdf = Ustring::new(xfdf);
- unsafe {
- ffi::TRN_FDFDocCreateFromXFDF(xfdf.to_ustring(), &mut fdf);
- ffi::TRN_PDFDocFDFMerge(self.doc, fdf);
- }
- self
- }
- }
- impl Drop for PDFDoc {
- fn drop(&mut self) {
- println!("dropped");
- if self.doc != std::ptr::null_mut() {
- unsafe {
- ffi::TRN_PDFDocDestroy(self.doc);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement