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 8207331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:57:49+00:00 2026-06-07T08:57:49+00:00

I need to embed some custom meta data to a PDF file using the

  • 0

I need to embed some custom meta data to a PDF file using the Apple’s Objective C SDK. Is there any working sample code available that does that?

What I need is very basic. Open an existing pdf and add some meta data and then save it.

Example of information stored will be like…. a customer’s name, contact number, items ordered.

I saw that this “CGPDFContextAddDocumentMetadata” supports metadata but I don’t know how the meta data look like and how is it used passed to this function.

Any help will be greatly appreciated…:)

  • 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-06-07T08:57:50+00:00Added an answer on June 7, 2026 at 8:57 am

    Metadata is metadata (of course, it is recommended by Adobe that you use XMP XML). So long as you create a valid CFDataRef and pass it into arg two, you’re pretty much good to go with anything. For example, here’s how to pass the string “Hello World” into a PDF’s metadata:

    void MakeAPDF()
    {
    
        CGRect mediaRect = CGRectMake(0, 0, 400, 600);
        // use your own rect instead
    
        CFMutableDataRef result = CFDataCreateMutable(kCFAllocatorDefault, 0);
        CGDataConsumerRef PDFDataConsumer = CGDataConsumerCreateWithCFData(result);
    
        // mark the PDF as coming from your program
        CFMutableDictionaryRef auxInfo = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, NULL, NULL);
        CFDictionaryAddValue(auxInfo, kCGPDFContextCreator, CFSTR("Your Programs Name"));
        CFDictionaryRef auxillaryInformation = CFDictionaryCreateCopy(kCFAllocatorDefault, auxInfo);
        CFRelease(auxInfo);
    
        // create a context to draw into
        CGContextRef graphicContext = CGPDFContextCreate(PDFDataConsumer, &mediaRect, auxillaryInformation);
        CFRelease(auxillaryInformation);
        CGDataConsumerRelease(PDFDataConsumer);
    
        // actually make the call to embed your String
        NSString* str= @"Hello World";
        NSData* data=[str dataUsingEncoding:NSUTF8StringEncoding];
        CFDataRef cfdata = CFDataCreate(NULL, [data bytes], [data length]);
    
        CGPDFContextAddDocumentMetadata(graphicContext, cfdata);
    
        CGContextBeginPage(graphicContext, &mediaRect);
        // do your drawing, like this grey rectangle
        CGContextSetGrayFillColor(graphicContext, 0.5, 0.5);
        CGContextAddRect(graphicContext, mediaRect);
        CGContextFillPath(graphicContext);
        // end your drawing
    
        CGContextEndPage(graphicContext);
        CGContextFlush(graphicContext);
        CGPDFContextClose(graphicContext);    
    }
    

    An XMP file might look like this:

    <?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
    <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.1-c041">
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
    <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
      <dc:format>application/pdf</dc:format>
      <dc:title>
        <rdf:Alt>
          <rdf:li />
        </rdf:Alt>
      </dc:title>
      <dc:description>
        <rdf:Alt>
          <rdf:li />
        </rdf:Alt>
      </dc:description>
      <dc:creator>
        <rdf:Seq>
          <rdf:li />
        </rdf:Seq>
      </dc:creator>
    </rdf:Description>
    <rdf:Description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
      <pdf:Keywords />
      <pdf:Producer />
    </rdf:Description>
    <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
      <xmp:CreatorTool />
      <xmp:CreateDate>2011-02-10T11:41:05+02:00</xmp:CreateDate>
      <xmp:ModifyDate>2011-02-10T11:41:06+02:00</xmp:ModifyDate>
    </rdf:Description></rdf:RDF>
    </x:xmpmeta>
    <?xpacket end="w"?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm loading a partialview using an ajax actionlink, but need to embed some
I need to build a javascript file on the fly and embed some html
I need to embed a link into a generated pdf in a ruby on
I need a solution to embed a pdf inside a flash screen i.e. want
Need help getting Ember-Data working with Zend Rest. At first, I'm familiar with Zend
I need to retrieve some details from a MusicXML (xml) file in Java. I
I have a c++ server side project that I need to embed some sort
I have a Silverlight application that I need to embed some less-than-common fonts in.
I'm using the django-oembed app to embed (among other content) some flickr photos: Using
I need to embed the bibliography information from the .bbl file in the .tex

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.