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

Working With Bookmarks When Merging PDFs

Wed, May 8 2019, 10:25 AM (US Eastern Time)

When merging PDFs together using DynamicPDF Merger or Core Suite, all bookmarks (or outlines) will be added to the output PDF by default. They will appear in the order they are merged, with the first document's bookmarks coming first, followed by the next document's bookmarks. However, this is not always the desired behavior, so let's take a look at a couple of other options.

Adding a Bookmark For Each Document

Sometimes you may want to add a bookmark for each document, but remove any of the bookmarks that are in the original PDFs. Accomplishing this can easily be done by adding a bookmark for each document and setting the Outlines merge option to false:

MergeDocument document = new MergeDocument();
MergeOptions mergeOptions = MergeOptions.Append;
mergeOptions.Outlines = false;
document.Outlines.Add("Bookmark for PDF", new XYDestination(document.Pages.Count + 1, 0, 0));
document.Append(fileName, mergeOptions);

The full example file is available here.

Organizing Bookmarks For Each Document

Other times you may want to add a bookmark for each document and place the original document's bookmarks as children. This can quickly be done by creating a bookmark for each document and setting the RootOutline merge option property to that bookmark:

MergeDocument document = new MergeDocument();
MergeOptions mergeOptions = MergeOptions.Append;
Outline outline = document.Outlines.Add("Parent Bookmark for PDF",
    new XYDestination(document.Pages.Count + 1, 0, 0));
mergeOptions.RootOutline = outline;
document.Append(fileName, mergeOptions);

The full example file is available here.

Wrap Up

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

https://github.com/DynamicPDF/dotnet-merge-pdf-bookmarks

There are of course many other options for how you may want to deal with bookmarks as well. 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: , , , , , ,

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

Splitting a PDF from .NET (C# Code Provided)

by Anil S

Tue, May 22 2012, 1:47 PM (US Eastern Time)

We get a decent amount of people who ask us about dynamically splitting a PDF.  Splitting a PDF document using DynamicPDF Merger for .Net is a very simple task. With the few lines of code the document can be split efficiently at the desired page. Use of PdfDocument object allows for efficient reuse of imported PDF document data. If the same PDF needs to be reused in multiple parts of the application, load the PDF into a PdfDocument object and use it where ever needed. Also the PdfDocument object is designed to be thread safe.
 
Let’s take a look at an example where we want to take a PDF file (pdfToSplit.pdf) and split it into two files (pdfA.pdf and pdfB.pdf).  The first PDF split (pdfA.pdf) will contain the first 50 pages of the file while the second PDF (pdfB.pdf) will contain all remaining pages.  Notice that we do not need to know how many pages the original PDF contained by utilizing the PdfDocument’s Pages.Count method.

            //Create a PdfDocument object to load the PDF.
            PdfDocument pdfToSplit = new PdfDocument("pdfToSplit.pdf");

            //Page number to split the document at. 
            int pageNumToSplit = 50;

            //Add first 50 pages and call the Draw method to save the PDF. 
            MergeDocument firstPdf = new MergeDocument(pdfToSplit, 1, pageNumToSplit);
            firstPdf.Draw("pdfA.pdf");

            //Add the remaining pages to a second document and save the PDF. 
            MergeDocument secondPDF = new MergeDocument(pdfToSplit, pageNumToSplit + 1, pdfToSplit.Pages.Count - pageNumToSplit);
            secondPDF.Draw("pdfB.pdf");

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