Skip to main content
Participant
June 19, 2025
Question

Issue: Drawing Tool (Freetext) Not Applying Default Color in Adobe PDF Embed API (Post-Update)

  • June 19, 2025
  • 0 replies
  • 101 views

I am experiencing unexpected behavior with the drawing tool (freetext annotation) in the Adobe PDF Embed API. Following a recent update to the SDK (not documented in the release notes for this specific functionality), the tool no longer defaults to the blue color (#0a23f5), even though the previewAnnotationColorMap setting is correctly defined in my GET_USER_SETTING_API implementation.

Problem Description:

Prior to a recent viewer.js update, when a user selected the "freehand drawing" or "freetext" tool (commonly used for signatures), the default color for this annotation was blue (#0a23f5), as configured by us. However, now the tool appears with a different color (seems to be black or the last color used by the user), which goes against our requirements for signatures.

I have reviewed the PDF Embed API release notes and have not found any mention of changes directly affecting the previewAnnotationColorMap functionality for freetext annotations.

Environment:

  • Affected Browser(s): [e.g., Google Chrome Version 125.0.6422.112, Mozilla Firefox Version 126.0.1, Microsoft Edge, Safari, etc.]
  • Operating System: [e.g., Windows 11, macOS Sonoma 14.4.1, Ubuntu 22.04 LTS]
  • Frontend Framework: React
  • Adobe PDF Embed API Client ID: [Confirm that your Client ID is correctly configured and working for other API functionalities.]
  • PDF URL: [If possible and secure, you can mention if the issue occurs with any PDF or a specific one.]

Relevant Code:

Below are the key parts of my code that handle SDK loading and user settings:

  1. SDK Script Loading:

We are loading the latest SDK version directly from Adobe's CDN:

// Inside my React component
useEffect(() => {
  if (isOpen && pdfUrl) {
    const scriptId = "adobe-view-sdk";
    let script = document.getElementById(scriptId);

    if (!script) {
      script = document.createElement("script");
      script.id = scriptId;
      script.src="https://acrobatservices.adobe.com/view-sdk/viewer.js"; // Loads the latest version
      script.onload = () => {
        document.addEventListener("adobe_dc_view_sdk.ready", initializeAdobeViewer, { once: true });
      };
      document.body.appendChild(script);
    } else {
      initializeAdobeViewer();
    }
  }
}, [isOpen, pdfUrl]);


2. getUserSettingHandler Implementation (where color is defined):

This function is responsible for setting the default user configuration, including the annotation color map. This is where the blue color for freetext is specified:

// Inside the initializeAdobeViewer function
const getUserSettingHandler = () => {
  return new Promise((resolve) => {
    console.log("🎨 Using default configuration.");
    resolve({
      code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
      data: {
        setting: {
          previewAnnotationColorMap: {
            freetext: "#0a23f5", // <--- This is the color that is no longer applied by default
            note: "#0a23f5",
            shape: "#0a23f5",
            highlight: "#0a23f5",
            underline: "#0a23f5",
            strikeout: "#0a23f5",
          },
          annotationTooltipShownMap: {
            freetext: false,
            note: false,
            shape: true,
            highlight: false,
            underline: false,
            strikeout: false,
          },
        },
      },
    });
  });
};


3. GET_USER_SETTING_API Callback Registration:

Confirming that the callback is correctly registered:

// Inside the initializeAdobeViewer function
adobeDCView.registerCallback(
  AdobeDC.View.Enum.CallbackType.GET_USER_SETTING_API,
  getUserSettingHandler,
  {}
);

4. previewFile Options (Annotations Enabled):

Confirming that the annotation API and tools are enabled:

// Inside the initializeAdobeViewer function
adobeDCView.previewFile(
  {
    content: { location: { url: pdfUrl } },
    metaData: { fileName: pdfName || "Documento PDF" },
  },
  {
    showPrintPDF: false,
    showFullScreenViewButton: false,
    enableAnnotationAPI: true, // Annotation API enabled
    showAnnotationTools: true, // Annotation tools visible
  }
);


Request:

I would appreciate any guidance on whether this is a known bug, an undocumented change in behavior, or if there is a new recommended way to ensure the drawing tool starts with a specific default color (in our case, blue).