Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4327278
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:30:56+00:00 2026-05-21T09:30:56+00:00

I currently have the following class that I’m trying to add a Hashtable of

  • 0

I currently have the following class that I’m trying to add a Hashtable of metadata properties to a PDF. The problem is, even though it appears to assign the hashtable to the stamper.MoreInfo property it doesn’t appear to save the MoreInfo property once the stamper is closed.

    public class PdfEnricher
{
    readonly IFileSystem fileSystem;

    public PdfEnricher(IFileSystem fileSystem)
    {
        this.fileSystem = fileSystem;
    }

    public void Enrich(string pdfFile, Hashtable fields)
    {
        if (!fileSystem.FileExists(pdfFile)) return;

        var newFile = GetNewFileName(pdfFile);
        var stamper = GetStamper(pdfFile, newFile);

        SetFieldsAndClose(stamper, fields);
    }

    string GetNewFileName(string pdfFile)
    {
        return fileSystem.GetDirectoryName(pdfFile) + @"\NewFileName.pdf";
    }

    static void SetFieldsAndClose(PdfStamper stamper, Hashtable fields)
    {
        stamper.MoreInfo = fields;
        stamper.FormFlattening = true;
        stamper.Close();
    }

    static PdfStamper GetStamper(string pdfFile, string newFile)
    {
        var reader = new PdfReader(pdfFile);
        return new PdfStamper(reader, new FileStream(newFile, FileMode.Create));
    }
}

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:30:56+00:00Added an answer on May 21, 2026 at 9:30 am

    As always, Use The Source.

    • In this case, I saw a possibility fairly quickly (Java source btw):

      public void close() throws DocumentException, IOException {
        if (!hasSignature) {
          stamper.close( moreInfo );
          return;
        }

    Does this form already have signatures of some sort? Lets see when hasSignatures would be true.

    That can’t be the case with your source. hasSignatures is only set when you sign a PDF via PdfStamper.createSignature(…), so that’s clearly not it.

    • Err… how are you checking that your MoreInfo was added? It won’t be in the XMP metadata. MoreInfo is added directly to the Doc Info dictionary. You see them in the “Custom” tab of Acrobat (and most likely Reader, though I don’t have it handy at the moment).

    • Are you absolutely sure MoreInfo isn’t null, and all its values aren’t null?

    • The Dictionary is just passed around by reference, so any changes (in another thread) would be reflected in the PDF as it was written.


    The correct way to iterate through a document’s “Doc info dictionary”:

    PdfReader reader = new PdfReader(somePath);
    Map<String, String> info = reader.getInfo();
    
    for (String key : info.keySet()) {
      System.out.println( key + ": " + info.get(key) );
    }
    

    Note that this will go through all the fields in the document info dictionary, not just the custom ones. Also be aware that changes made the the Map from getInfo() will not carry over to the PDF. The map is new’ed, populated, and returned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem. I am currently trying to return information from a
I currently have the following models/toy.rb file in my RoR project: class ToysPurchased include
I currently have a class file with the following enumeration: using System; namespace Helper
I currently have a class where I need accomplish the equivalent of the following
I currently have the following SQL query that lists all the names of all
I currently have the following: class Question < ActiveRecord::Base belongs_to :product belongs_to :user belongs_to
I currently have the following code that retrieves data from the database and then
I currently have a class that uses the KeyValuePair with List to store a
I currently have created a pagination JavaScript class that will automatically paginate comments when
I have a viewmodel class for a create view that consists of 2 properties

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.