Creating PDFs with Custom XMP Schema's

Mon, June 3 2019, 4:23 PM (US Eastern Time)

XMP metadata is a powerful tool for describing the contents of a PDF document. DynamicPDF has built in support for many of the most popular schemas:

However, there are times when you may need to embed other metadata in a PDF. This can easily be done by creating a class that inherits from the XmpSchema base class and overriding the Draw method. This Draw method will then be called when the XMP metadata is being added to the PDF. First let’s define a CustomSchema class that inherits from XmpSchema:

class CustomSchema : XmpSchema
{
    private string userName;
    private DateTime creationDate;

    public CustomSchema(string userName, DateTime creationDate)
    {
        this.userName = userName;
        this.creationDate = creationDate;
    }

    protected override void Draw(XmpWriter xmpWriter)
    {
        xmpWriter.BeginDescription("http://ns.adobe.com/xap/1.0/", "xmp", " ");
        if (userName != null) xmpWriter.Draw("\t\t" + userName + "\n");
        xmpWriter.Draw("\t\t" + creationDate.ToString("yyyy-MM-dd'T'HH:mm:sszzz") + "\n");
        xmpWriter.Draw("\t\t" + xmpWriter.Producer + "\n");
        xmpWriter.Draw("\t\t" + xmpWriter.Date.ToLocalTime().ToString("yyyy-MM-dd'T'HH:mm:sszzz") + "\n");
        xmpWriter.EndDescription();
    }
}

Notice that the Draw method starts by calling the BeginDescription method and ends by calling the EndDescription method. XMP metadata is XML based, and these methods are responsible for the opening and closing XML tags for the custom schema. The Draw method that is called multiple times between them is then responsible for outputting the other XML data.

Next, we will add the CustomSchema class we created to the XMP metatdata of the document:

XmpMetadata xmpMetadata = new XmpMetadata();
xmpMetadata.AddSchema(new CustomSchema("John", DateTime.Now));
document.XmpMetadata = xmpMetadata;

The following custom metatdata will now appear in the PDFs XMP metadata:

<rdf:Description rdf:about=' ' xmlns:xmp='http://ns.adobe.com/xap/1.0/'>
    <xmp:CreatedBy>John</xmp:CreatedBy>
    <xmp:DateCreated>2019-06-03T16:18:17-04:00</xmp:DateCreated>
    <xmp:CreatorTool>DynamicPDF for .NET v10.12.0.40 (Build 38759)</xmp:CreatorTool>
    <xmp:MetadataDate>2019-06-03T16:18:17-04:00</xmp:MetadataDate>
</rdf:Description>
Wrap Up

A C# Visual Studio project demonstrating this is available on GitHub:

https://github.com/DynamicPDF/dotnet-custom-xmp-schemas

If you have any questions or comments, I would love to hear from you.

Tags: , , , , , ,

DynamicPDF for .NET Core Suite Version 9 BETA Release

Thu, April 27 2017, 2:16 PM (US Eastern Time)

The DynamicPDF Core Suite for .NET Version 9.0 BETA has just been posted to our site for download and testing.

DynamicPDF Core Suite for .NET v9 Beta Download

We have added some great new features in version 9 including support for PDF portfolios, an HTML Area, XFA static form filling, improved memory handling for large PDFs, several new barcode types (Code 93, Aztec, GS1 Databar, Australia Post, Singapore Post etc.) and more. Take a look at the full list of new features.

Email support@cete.com with any questions or issues and thanks for taking part in our Version 9 BETA.

 

Tags: , , , , , , , , , ,

DynamicPDF for Java Version 8 Release

by Anil S

Fri, September 25 2015, 2:02 PM (US Eastern Time)

Our DynamicPDF for Java version 8 has now been fully released.  Download it Today!

This version 8 includes DynamicPDF Generator & Merger. The download includes the updated documentation and examples (Java source code, Servlets, JSPs).

Version 8 adds lots of new features including additional support for PDF/A-2, PDF/A-3, MSI (Modified Plessey) & RM4SCC (Royal Mail) barcodes, strikethrough text, duplicate image removal, individual form field flattening as well as overall efficiency improvements and stabilizations. Take a look at our Version 8 Full Feature List.

For existing customers, eligible upgrades (free with Maintenance, discounted with previous versions) can be accessed via our Customer Area, www.dynamicpdf.com/customerarea or anyone can contact us directly, sales@cete.com or +1 410.772.8620.

Tags: , , , , , ,

DynamicPDF Core Suite for .NET v7.0.1 Release

Mon, July 16 2012, 1:12 PM (US Eastern Time)

The 7.0.1 update of DynamicPDF Core Suite for .NET (Generator, Merger and ReportWriter) has now been released on our website (download it here).  This update addresses a few bug fixes, enhancements and depreciated items but the functionality that takes center stage here is the new encryption algorithms that have been added.  Version 7.0.1 has added support for AES 128-bit and 256-bit encryption algorithms as well as crypt filters.  We will elaborate on these new encryption features in a future post but for now, take a look at the Help Library's page:

More detailed information regarding v7.0.1 can be found here:

Are there any new features that you would like to see in our DynamicPDF components? Let me know by commenting below.

Tags: , , , , ,

Generating PDFs Dynamically on Android

Fri, June 15 2012, 11:35 AM (US Eastern Time)

I have been using an Android phone for a few years now, and one day I decided I should try to write an Android application using our DynamicPDF Generator for Java. So I decided to start off with a simple "Hello World" application based on the DynamicPDF Generator hello world PDF java example provided with the Generator product.

My goal was to create a PDF on the Android phone when the application was run. I wanted to keep it simple and not even bother with having a GUI for it at this point.

I already had my machine set up with Eclipse IDE, the ADT (Android Developers Tool) plugin and the Android SDK. Here are the steps I followed to create the Android application:

  1. I created a new Android project in Eclipse with the details below. Android version 2.1 is what I tested with, since that is the lowest SDK version I had installed, but it may work with an older version of Android too.

    Project name: HelloWorld
    Build Target: Android 2.1
    Application name: Hello World
    Package name: com.cete.androidexamples.dynamicpdf.helloworld
    Create Activity: DynamicPDFHelloWorld
    Minimum SDK: 7

  2. Since I knew my application had to write to the SD card to output the PDF, I added the WRITE_EXTERNAL_STORAGE permission in the AndroidManifest.xml:
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  3. More...

Tags: , , , ,

Dynamic PDF for .NET Core Suite Version 7 Release

Fri, May 11 2012, 1:21 PM (US Eastern Time)

DynamicPDF Core Suite for .NET v7 is now released!  Thanks to everyone who participated in the beta testing and helped make this release a success.  The full press release can be found here.

You asked…we listened. Great new features like QR Codes, Text Extraction and True Form Flattening were being requested by the community and those features are now here in version 7.  Check out a full list of new features here.

Now that version 7 is released, what new features would you love to see in future versions?  Comment below and let us know.

Tags: , , , , ,

Month List