Some test text!

Search
Hamburger Icon

Web / Guides / Custom stamps

Create Custom PDF Stamps using JavaScript

By default WebViewer includes several standard stamps that are part of the PDF specification, but it also supports the creation of custom stamps with custom text and colors. You can control the standard and custom stamps that show up by default in the UI by using the APIs described below.

Standard stamps

To get a list of the standard stamps you can call getDefaultStamps and to update the list you can call setStandardStamps. Stamps in this list will show up in the UI under the standard tab.

Default standard stamps:

  • Approved
  • AsIs
  • Completed
  • Confidential
  • Departmental
  • Draft
  • Experimental
  • Expired
  • Final
  • ForComment
  • ForPublicRelease
  • InformationOnly
  • NotApproved
  • NotForPublicRelease
  • PreliminaryResults
  • Sold
  • TopSecret
  • Void
  • SHSignHere
  • SHWitness
  • SHInitialHere
  • SHAccepted
  • SBRejected

For example you can add an image URL to the list so that it shows up in the standard list:

Webviewer({...}, wvElement).then(instance => {
  const { documentViewer } = instance.Core;

  // This relative path will most likely be different (replace image). Don't expect this to work for you.
  const pathToLogo = '/envs/image.png';
  const tool = documentViewer.getTool('AnnotationCreateRubberStamp');

  tool.setStandardStamps([
    'Approved',
    'AsIs',
    pathToLogo,
  ]);
})

standard stamp

Custom stamps

WebViewer also supports adding custom stamps with a custom label, timestamp text and color. To create custom stamps, pass an array of stamp objects to the setCustomStamps method of AnnotationCreateRubberStamp tool.

Webviewer({...}, wvElement).then(instance => {
  const { documentViewer, Annotations } = instance.Core;

  const tool = documentViewer.getTool('AnnotationCreateRubberStamp');

  const customStamps = [
    { title: "Approved", subtitle: "[By $currentUser at] h:mm:ss a, MMMM D, YYYY" },
    { title: "Reviewed", subtitle: "[By $currentUser at] h:mm:ss a, MMMM D, YYYY", color: new Annotations.Color('#D65656') },
  ]
  tool.setCustomStamps(customStamps)
})

These custom stamps will show up by default in the UI under the custom tab:

custom stamp

Custom stamps can also manually be created by users from this UI tab.

Get the answers you need: Chat with us