• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dynamic Image Stamp

New Here ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

Im working on setting up a Stamp that will pull the users Signature from a network folder.  I bought the PDF Stamps gone wild bookd an used the code below.  
The code works if your signature are in a PDF format... The problem im having is all of my users signatures are in the PNG format not PDF.  when I change the code below from PDF to PNG, it does not work.  
How would I use the script below to insert a signatre stamp image where the image file is a PNG and not a PDF?  

===============================================

****Trusted Function Script ****

var MyImportIcon = app.trustedFunction (function (oFld, cPath)
{
    app.beginPriv();
    if(cPath != null)
    { // Works for a stamp script  
        oFld.buttonImportIcon(cPath,0);
    }
    else
    { //Works for regular PDFs, but not a stamp
        oFld.buttonImportIcon();
    }
    app.endPriv();
});
 
==================================================
****Folder Level Script ****
 

event.value = identity.name;

// Get image name
var cImageName = identity.name.replace(/\s+/g,"_");
//Build full path to image file
var cFileName = "/H/Images/Signatures/" + cImageName;
cFileName += ".";

try{
MyImportIcon(this.getField("SigButtonImage"), cFileName);
}catch(e){
console.println("Error Importing Signature Image")
}

 Capture.PNG
TOPICS
JavaScript

Views

491

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 27, 2023 Jul 27, 2023

Copy link to clipboard

Copied

Are you sure the file path is correct? Why are you adding just a period to the end of it, and not the full file extension?

If the path is correct it should work just fine.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 28, 2023 Jul 28, 2023

Copy link to clipboard

Copied

The path is correct, I have 2 documents in that same location with the same name, one has a .PDF extension, the other has a .png extension, when I make the extension a .pdf it works like it should. but if I change the code to .png it does not work.
But if I change the extension to a .png or .gif etc it does not work.  Does not throw an error, what it does, is when I go into a PDF file and then try to use the stamp, it flashes CANCLE 3 times quickly. 

Here is the fixed script from above with the .png added.  even haveing .png in there does not seem to work. 
Also see the attached screen shot of the cancle error flashing 3 times.AdobeStampError.png

=====================================

****Folder Level Script ****
 

event.value = identity.name;

// Get image name
var cImageName = identity.name.replace(/\s+/g,"_");
//Build full path to image file
var cFileName = "/H/Images/Signatures/" + cImageName;
cFileName += ".png";

try{
MyImportIcon(this.getField("SigButtonImage"), cFileName);
}catch(e){
console.println("Error Importing Signature Image")
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 28, 2023 Jul 28, 2023

Copy link to clipboard

Copied

LATEST

Are you using this on Reader or Acrobat Pro?  

 

All of the image import functions have a sordid history.  They have worked differently in different versions of Acrobt. Sometimes they required privilege and sometimes they didn't.   When I wrote the book, Reader would not convert images for the import. The imported image had to be PDF. But Acrobat Pro would do the conversion from any image format. Also in DC the image import works differently in the Stamp context than a document context. For example,  in the stamp context the buttonImportIcon function won't work if the path is not specified. I think JR wrote an analysis/rant on this years ago.  None of this is properly documented and it's highly likely that things have changed in the latest update. 

I've tested the buttonImportIcon function recently from a document context, but not for a stamp.  And unfortunately I won't be able to get to it until later next week. 

The easiest work around, and the best protection from future Adobe shananagans, is to convert your signatures to PDFs.  In fact you can use the Signature Stamp tool to produce beautiful stamp images.

https://www.pdfscripting.com/public/PDF-Signature-Stamps.cfm

 

Then you'll also have a sigature stamp.

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines