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: , , , , , ,

Version 10 Release of Dynamic PDF for .NET Core Suite

by Anil S

Fri, August 3 2018, 2:32 PM (US Eastern Time)

We are happy to announce the release of DynamicPDF for .NET Core Suite v10 (this includes our Merger, Generator and ReportWriter products).

v10 now supports .NET Standard 2.0 for seamless cross-platform deployment.  

Download it Today!

Version 10 adds several useful and exciting new features:

  • Deployment to any .NET implementation including .NET Core, .NET Framework, Mono, UWP, Xamarin.iOS and Xamarin.Android.
  • HTML layout engine for rapid PDF development using HTML and CSS
  • All new report layout engine (DLEX templates)
  • Take a look at a full list of All Version 10 Full Features

Free upgrades for Maintenance customers, discounted upgrades for eligible existing customers, eligible upgrades can be accessed via our Customer Area, www.dynamicpdf.com/customerarea or we can be contacted directly, sales@dynamicpdf.com or +1 410.772.8620.

Version 9 Release of Dynamic PDF for .NET Core Suite

Tue, December 12 2017, 2:43 PM (US Eastern Time)

DynamicPDF for .NET Core Suite v9 (this includes our Merger, Generator and ReportWriter products) has now been fully released.  Download it Today!

Version 9 adds tons of useful and exciting new features including:

  • HTML Rendering (convert HTML pages including CSS)
  • Disk Buffering (incremental PDF rendering decreases memory usage)
  • Character Shaping (for fonts of complex scripts)
  • Over 20 New Barcodes (Aztec, Code 11, Code 93, GS1 Databar, Australia Post, etc.)
  • Package PDFs
  • XFA Static Form Filling
  • Document, Page and Field Actions
  • Take a look at a full list of All Version 9 Full Features

What might be our best feature...Lower Prices across the board (all editions, all license models).

Free upgrades for Maintenance customers, discounted upgrades for eligible existing customers, eligible upgrades can be accessed via our Customer Area, www.dynamicpdf.com/customerarea or we can be contacted directly, sales@cete.com or +1 410.772.8620.

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: , , , , , ,

Creating PDFs in C# with Outlined or Invisible Text

Thu, August 30 2012, 1:51 PM (US Eastern Time)

DynamicPDF Generator has lots of predefined page elements which allow you to easily create different types of content, but you may occasionally have a need to do something that is not available in the API by default. Custom page elements is an easy way to extend the API to achieve these results.

We get questions from time to time on how to add outlined text to a PDF. By outlined text I mean text that is not completely filled in with a color but rather is just an outline of the font and nothing filled in the middle of the text.  This is a great situation for using a Custom page element and the C# code below shows how to extend the TextArea page element to add this functionality:

using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

public class OutlinedTextArea : TextArea
{
    // Member variable to store Border Width
    private float borderWidth = 1.0f;

    // Constructors. Additional ones can be added to model TextArea
    public OutlinedTextArea(string text, float x, float y, float width, float height)
        : base(text, x, y, width, height) { }
    public OutlinedTextArea(string text, float x, float y, float width, float height,
        Font font, float fontSize)
        : base(text, x, y, width, height, font, fontSize) { }

    // Border Width Property added
    public float BorderWidth
    {
        get { return this.borderWidth; }
        set { this.borderWidth = value; }
    }

    // Override Draw Method
    public override void Draw(ceTe.DynamicPDF.IO.PageWriter writer)
    {
        // Enter Graphics Mode
        writer.SetGraphicsMode();
        // Set Stroke Color and Border Width
        writer.SetStrokeColor(base.TextColor);
        writer.SetLineWidth(this.borderWidth);
        // Enter Text Mode
        writer.SetTextMode();
        // Set Text Rendering Mode
        writer.SetTextRenderingMode(TextRenderingMode.Stroke);
        // Call Draw on base class
        base.Draw(writer);
        // Enter Text Mode (in case underline is set to true)
        writer.SetTextMode();
        // Set Text Rendering Mode Back to Fill
        writer.SetTextRenderingMode(TextRenderingMode.Fill);
    }
}

More...

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: , , , ,

Month List