Stamp not showing up after document save

Product: Listella

Product Version: Alpha

Please give a brief summary of your issue:
(Think of this as an email subject)

Stamper requires return navigation to show stamped image after save

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

I am able to use the Stamper on iOS to add a signature image, but I need to navigation away from the document and return to it, reloading the document, in order to see it.

Is there a call I need to make after saving the document that will refresh the document?

Please provide a link to a minimal sample where the issue is reproducible:

                            let doc: PTPDFDoc = PTPDFDoc(filepath: path)                            
                            doc.initSecurityHandler()                            
                            let stamper: PTStamper = PTStamper(size_type: e_ptrelative_scale, a: 0.25, b: 0.1)
                            stamper.setPosition(-150, vertical_distance: 135, use_percentage: false)
                             
                            if let imageData = image.pngData() {
                                let imageDateSize = imageData.count
                            
                                let set = PTObjSet()
                                let setArray = set?.createArray()
                                setArray?.pushBackName("Flate")
                                
                                let ptImage = PTImage.create(withDataSimple: doc.getSDFDoc(),
                                                             buf: imageData,
                                                             buf_size: UInt(imageDateSize),
                                                             encoder_hints: setArray)
                                
                                stamper.setAsBackground(false)
                                let lastPageSet = PTPageSet(one_page: doc.getPageCount()) /// add signature to last page
                                stamper.stampImage(doc,
                                                   src_img: ptImage,
                                                   dest_pages: lastPageSet)
                            }
                            
                            doc.save(toFile: path, flags: e_ptlinearized.rawValue)

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hello Mark,

Thank you for reaching out.

You are missing the PTPDFViewCtrl.update line after you stamp the image. It redraws the area occupied by the the annotation. Also you should be locking the document before doing any changes on it.

Your code would look something like this:

try pdfViewCtrl.docLock(true) { doc
   let doc: PTPDFDoc = PTPDFDoc(filepath: path)
   doc.initSecurityHandler()                              
   let stamper: PTStamper = PTStamper(size_type: e_ptrelative_scale, a: 0.25, b: 0.1)
   stamper.setPosition(-150, vertical_distance: 135, use_percentage: false)  
   if let imageData = image.pngData() {      
        let imageDateSize = imageData.count 
        let set = PTObjSet()      
        let setArray = set?.createArray() 
        setArray?.pushBackName("Flate")   
        let ptImage = PTImage.create(withDataSimple: doc.getSDFDoc(),  buf: imageData,  buf_size: UInt(imageDateSize),  encoder_hints: setArray) 
        stamper.setAsBackground(false) 
        let lastPageSet = PTPageSet(one_page: doc.getPageCount()) /// add signature to last page      
        stamper.stampImage(doc, src_img: ptImage, dest_pages: lastPageSet)
   }   
 // get the new annotation 
  if let page = doc.getPage(UInt32(self.pageNumber)) { 
      let numAnnots = page.getNumAnnots()     
      if let newAnnot = page.getAnnot(numAnnots-1) {         
           pdfViewCtrl.update(with: newAnnot, page_num: self.pageNumber)  
      }
  }      
doc.save(toFile: path, flags: e_ptlinearized.rawValue)
}

Let us know if this works for you.

Check your ticket status - https://support.pdftron.com/support/tickets/33303

Best Regards,

Sahil Behl

Software Developer

PDFTron Systems, Inc.

www.pdftron.com

Tel: 1-604-730-8989

Fax: 1-604-676-2477