Conformance Level PDFA

This example demonstrates how create PDF/A document.

Our PDF library adds the ability to create PDF/A document which is PDF/A is an ISO-standardized version of the Portable Document Format (PDF) specialized for use in the archiving and long-term preservation of electronic documents.

Click on the genearet button to see outpput PDF/A file

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using OfficeComponent.Pdf;
using OfficeComponent.Pdf.Graphics;

namespace OfficeComponent.Samples
{
    class ConformanceLevelPDFAExample : ExampleBase
    {
        public ConformanceLevelPDFAExample(string commonDataPath, string outputDir)
            : base(commonDataPath, outputDir)
        {
        }

        public ConformanceLevelPDFAExample(string commonDataPath, string outputDir, string xmlFile)
            : base(commonDataPath, outputDir, xmlFile)
        {
        }

        public override string Execute()
        {
            // Create a new instance of PdfDocument class.
            PdfDocument doc = new PdfDocument();

            PdfPage page = doc.Pages.Add();

            SizeF bounds = page.GetClientSize();

            //Read the RTF document
            StreamReader reader = new StreamReader(CommonDataPath + "\\EULA.rtf", Encoding.ASCII);
            string text = reader.ReadToEnd();
            reader.Close();

            //Convert it as metafile.
            PdfMetafile metafile = (PdfMetafile)PdfImage.FromRtf(text, bounds.Width, PdfImageType.Metafile);
            PdfMetafileLayoutSettings format = new PdfMetafileLayoutSettings();

            //Allow the text to flow multiple pages without any breaks.
            format.SplitTextLines = true;

            //Draw the image.
            metafile.Draw(page, 0, 0, format);


            // Save and close the document.
            var outputPath = Path.Combine(OutputDir, this.GetType().Name + "_" + Guid.NewGuid().ToString() + ".pdf");
            doc.Save(outputPath);
            doc.Close(true);

            return outputPath;
        }
       

    }

}
Imports System.IO
Imports System.Text
Imports OfficeComponent.Pdf
Imports OfficeComponent.Pdf.Graphics

Namespace OfficeComponent.Samples
	Friend Class ConformanceLevelPDFAExample
		Inherits ExampleBase
		Public Sub New(ByVal commonDataPath As String, ByVal outputDir As String)
			MyBase.New(commonDataPath, outputDir)
		End Sub

		Public Sub New(ByVal commonDataPath As String, ByVal outputDir As String, ByVal xmlFile As String)
			MyBase.New(commonDataPath, outputDir, xmlFile)
		End Sub

		Public Overrides Function Execute() As String
			' Create a new instance of PdfDocument class.
			Dim doc As New PdfDocument()

			Dim page As PdfPage = doc.Pages.Add()

			Dim bounds As SizeF = page.GetClientSize()

			'Read the RTF document
			Dim reader As New StreamReader(CommonDataPath & "\EULA.rtf", Encoding.ASCII)
			Dim text As String = reader.ReadToEnd()
			reader.Close()

			'Convert it as metafile.
			Dim metafile As PdfMetafile = CType(PdfImage.FromRtf(text, bounds.Width, PdfImageType.Metafile), PdfMetafile)
			Dim format As New PdfMetafileLayoutSettings()

			'Allow the text to flow multiple pages without any breaks.
			format.SplitTextLines = True

			'Draw the image.
			metafile.Draw(page, 0, 0, format)


			' Save and close the document.
			Dim outputPath = Path.Combine(OutputDir, Me.GetType().Name & "_" & Guid.NewGuid().ToString() & ".pdf")
			doc.Save(outputPath)
			doc.Close(True)

			Return outputPath
		End Function


	End Class

End Namespace