Skip to main content
Skip table of contents

Reading/Writing Additional Metadata in Mako

📌 Overview

This article addresses issues regarding the retrieval and modification of additional metadata in documents using Mako.

(question) Issue Description

For certain documents, Acrobat displays metadata such as:

  • Copyright information (Status, Notice and Info URL)

  • “Description Writer”

  • “Fast Web View”

The customer wanted to know if these are directly accessible or modifiable using Mako's current capabilities.

💡 Solution

To retrieve and modify metadata using Mako, follow these steps:

  1. Accessing Metadata

    • Use the Mako SDK to parse the document and access the metadata section.

    • Implement custom functions to extract specific metadata fields.

  2. Modifying Metadata

    • Once the metadata is accessed, use Mako's API to modify the fields as required.

    • Ensure that changes are saved back to the document correctly.

  3. Exceptional cases: Edit XMP packet

    • Some metadata fields may not be available using Mako’s APIs, See the table below for what properties are accessible with Mako.

    • In this case you will need update the XMP packet using a third party library

🗺️ Metadata Property Mapping

Acrobat Name

Mako Property Name

IDOMMetadata Type

Document Title

Title

eDocumentInfo

Author

Author

eDocumentInfo

Description

Subject

eDocumentInfo

Keywords

Keywords

eDocumentInfo

Application

Creator

eDocumentInfo

PDF Producer

Producer

eDocumentInfo

Created

CreationDate

eDocumentInfo

Modified

ModDate

eDocumentInfo

Trapped

Trapped

eDocumentInfo

PDF Version

Version

ePDFInfo

Fast Web View

Linearized

ePDFInfo

Tagged PDF

Marked

ePDFInfo

PDF/UA Compliance

Standard

ePDFInfo

Resize window to initial page

FitWindow

eViewerPreferences

Show (Document Title/File Name)

DisplayDocTitle

eViewerPreferences

DuplexMode

Duplex

eViewerPreferences

Paper Source by Page Size

PickTrayByPDFSize

eViewerPreferences

Hide tool bars

HideToolbar

eViewerPreferences

Hide menu bar

HideMenubar

eViewerPreferences

Hide window controls

HideWindowUI

eViewerPreferences

Page Scaling

PrintScaling

eViewerPreferences

Center window on screen

CenterWindow

eViewerPreferences

Number of Copies

NumCopies

eViewerPreferences

Navigation Tab

NonFullScreenPageMode

eViewerPreferences

Binding

Direction

eViewerPreferences

Open in Full Screen mode

PageMode

ePageView

Page layout

PageLayout

ePageView

Author Title

There is no built-in Mako property for these fields.

However, this information is accessible. See this code sample on GitHub that demonstrates accessing and modifying the XMP packet directly.

photoshop:AuthorsPosition (XMP packet)

Description Writer

photoshop:CaptionWriter (XMP packet)

Copyright Status

xmpRights:Marked (XMP packet)

Copyright Notice

dc:rights (XMP packet)

Copyright Info URL

xmpRights:WebStatement (XMP packet)

Format

dc:format (XMP packet)

⌨️ Sample Code

Below is a sample code snippet to get you started with accessing and modifying metadata. There is a longer example on our GitHub, MakoPDFMetadata.cpp, which makes use of these APIs, and also shows how to retrieve and edit the XMP data. To parse the XML in the XMP packet, you will need an XML library.

CPP
const auto mako = IJawsMako::create();
mako->enableAllFeatures(mako);
const auto assembly = IInput::create(mako, eFFPDF)->open("path/to/your/document.pdf");

// Get Metadata
auto metadata = assembly->getJobMetadata();
PValue pVal;
metadata->getProperty(IDOMMetadata::eDocumentInfo, "Title", pVal);
auto titleString = pVal.getString();
std::wcout << "The title of this PDF is: " << titleString << '
';

// Set Metadata
metadata->setProperty(IDOMMetadata::eDocumentInfo, "Title", PValue("New title for this PDF"));

// Check if metadata is null and create if necessary
if (metadata == nullptr)
{
    metadata = IDOMMetadata::create(mako); 
    metadata->setProperty(IDOMMetadata::eDocumentInfo, "Title", PValue("New title for this PDF"));
    assembly->setJobMetadata(metadata);
}

☑️ Conclusion

While Mako provides robust tools for document manipulation, accessing and modifying certain metadata fields may require additional custom development. For further assistance, please contact Mako support.

📚 Additional Resources

If you need additional help, see our API documentation for detailed information on class/method usage, or raise a support ticket via our customer portal.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.