3-Heights™ PDF Toolbox – developer component for PDF processing

The 3-Heights™ PDF Toolbox API is a highly performant, platform independent component for creating and assembling conforming PDF/A documents.

Assemble

Assemble PDF documents from any source

Enrich

Enrich PDF documents with additional information, such as stamps

Create

Create new pages with any content and add them to your PDF documents

PDF Toolbox - Advanced PDF manipulation - edit and composite your PDF documents

PDF toolbox - features

Document assembly

  • Copy pages from existing PDFs
  • Copy annotations, form fields, links, logical structure, destinations, outlines, layers
  • Flatten annotations, form fields, signatures
  • Optimize resources
  • Crop and rotate pages
  • Free composition of content: Overlays, Underlays, Stamps, Transformations
  • Encryption: User password, Owner password, Permissions
  • Copy and modify document metadata
  • Copy and modify page metadata

Content generation

  • Create new PDF content from scratch
  • Apply content to existing pages

Colors

  • Device colors: RGB, CMYK and Grayscale
  • ICC color profiles
  • Transparency: Alpha and Blend mode

Paths

  • Single and Multi-segment lines
  • Rectangle, Circle, Bezier curves, Ellipse, Arc, Pie
  • Filling, stroking, clipping and combinations thereof
  • Line width, cap, join, dash array, dash phase and miter limit
  • Inside rule: Nonzero winding rule, Even/odd rule

Text

  • Font size, Character spacing, Word spacing
  • Horizontal scaling, leading, rise
  • Enables simple text layouting
  • Standard PDF fonts, installed fonts
  • Font metrics: Italic angle, Ascent, Descent, Cap height, Character width
  • Unicode characters
  • Text stroke: Line width, Line join and Dashes
  • Fill and stroke text, invisible text
  • Use text as clipping path

Images

  • Bi-level: CCITT G3, G3 2D and G4, Flate, LZW, Packbits, uncompressed
  • 4 bit and 8 bit grayscale: Flate, LZW, Packbits, JPEG and JPEG-6 (8 bit only), uncompressed
  • RGB: Flate, JPEG and JPEG-6, LZW, Packbits, uncompressed

Transformations

  • Translation
  • Scaling
  • Skewing (Horizontal, Vertical)
  • Rotation

Content Modification

  • Selective copying of content elements (without markup)
  • Geometric transformation of content elements

Extraction

  • Document and Page
    • Document information entries: Title, Author, Subject, Keywords, Creator, Producer, Creation date, Modification date
    • Document XMP metadata
    • Page bounding boxes: Media box, Crop box, Bleed box, Trim box, Art box
    • Page XMP metadata
  • Content
    • Page’s and group’s content elements including
      • Bounding box
      • Affine transformation
    • As either of the following:
      • Group element
      • Image element
        • Width and height in pixel
        • Bits per component
        • Color space
    • Image mask element
      • Width and height in pixel
      • Paint for filling the mask
    • Path element
      • Alignment box
      • Fill parameters including paint and fill rule
      • Stroke parameters including line paint and line style
    • Shading element
    • Text element
      • Text fragments
        • Bounding box
        • Affine transformation
        • Unicode string
        • Fill parameters including paint and fill rule
        • Stroke parameters including line paint and line style
  • Annotations
    • Signature fields: Name, Location, Reason, Contact info, Date, Visibility

Conformance

  • ISO 32000-1 (PDF 1.7)
  • ISO 32000-2 (PDF 2.0)
  • ISO 19005-1 (PDF/A-1)
  • ISO 19005-2 (PDF/A-2)
  • ISO 19005-3 (PDF/A-3)

Supported formats

Supported PDF Formats

  • PDF 1.0 to 1.7
  • PDF 2.0
  • PDF/A-1, PDF/A-2, PDF/A-3

Supported image formats

  • BMP
  • DIB
  • JPEG
  • JPEG2000
  • JBIG2
  • PNG
  • GIF
  • TIFF

Supported Font Formats

  • Type1
  • TrueType
  • OpenType
  • OpenType (CFF)
Magnifying lens for our PDF manuals and PDF sample code

MANUAL

API

Areas of use - edit and composite PDF documents

PDF generation

Programmatic creation of any PDF/A-conform document, whereby its content can stem from any source such as a database or webpage form.

Personalization

PDF documents are used for distributing e-books as well as for creating invoices, contracts and terms and conditions, for instance in insurance application forms. These documents share a common requirement: they need to be supplemented with data specific to the recipient.

Automated reporting

Large quantities of information are stored in databases and DMS systems. PDF Toolbox is designed to receive this information and convert it into distributable standardized PDF documents. It therefore enables the distribution of documents across infrastructures where different technologies and operating systems are in use.

Other areas of use

  • Mass production of invoices, reports, etc.
  • PDF creation "on-the-fly" in web server applications
  • "Save as PDF/A" function in application programs
  • Import images and text in PDF/A documents

Add stamp to PDF

Add a transparent stamp text onto each page of a PDF document. Optionally specify the color and the opacity of the stamp.

C# sample:
// Open input document
using (Stream inStream = new FileStream(inPath, FileMode.Open, FileAccess.Read))
using (Document inDoc = Document.Open(inStream, null))

// Create output document
using (Stream outStream = new FileStream(outPath, FileMode.Create, FileAccess.ReadWrite))
using (Document outDoc = Document.Create(outStream, Conformance.Unknown, null))
using (Font font = outDoc.CreateSystemFont("Arial", "Italic", true))
{
    // Set output intent
    if (inDoc.OutputIntent != null)
        using (ColorSpace outputIntent = outDoc.CopyColorSpace(inDoc.OutputIntent))
            outDoc.OutputIntent = outputIntent;

    // Copy metadata
    using (Metadata metadata = outDoc.CopyMetadata(inDoc.Metadata))
        outDoc.Metadata = metadata;

    // Set copy options
    CopyOption copyOptions = CopyOption.CopyLinks | CopyOption.CopyAnnotations | 
        CopyOption.CopyFormFields | CopyOption.CopyOutlines | CopyOption.CopyLogicalStructure;

    // Get the device color space
    using (ColorSpace colorspace = outDoc.CreateDeviceColorSpace(DeviceColorSpaceType.RGB))
    // Create paint object with the choosen RGB color
    using (paint = outDoc.CreateAlphaPaint(colorspace, alpha, 1.0, 0.0, 0.0))
    {
        // Loop through all pages of input
        foreach (Page inPage in inDoc.Pages)
        {
            // Copy page from input to output
            using (Page outPage = outDoc.CopyPage(inPage, copyOptions))
            {
                // Add text to page
                AddStamp(outDoc, outPage, stampString, font, 50);

                // Add page to document
                outDoc.Pages.Add(outPage);
            }
        }
    }
}
private static void AddStamp(Document outputDoc, Page outPage, string stampString, 
    Font font, double fontSize)
{
    // Create content generator and text object
    using (ContentGenerator gen = new ContentGenerator(outPage.Content, false))
    using (Text text = outputDoc.CreateText())
    {
        // Create text generator
        using (TextGenerator textgenerator = new TextGenerator(text, font, fontSize, null))
        {
            // Calculate point and angle of rotation
            Point rotationCenter = new Point
            {
                X = outPage.Size.Width / 2.0,
                Y = outPage.Size.Height / 2.0
            };
            double rotationAngle = Math.Atan2(outPage.Size.Height,
                outPage.Size.Width) / Math.PI * 180.0;

            // Rotate textinput around the calculated position
            Transformation trans = new Transformation();
            trans.RotateAround(rotationAngle, rotationCenter);
            gen.Transform(trans);

            // Calculate position
            Point position = new Point
            {
                X = (outPage.Size.Width - textgenerator.GetWidth(stampString)) / 2.0,
                Y = (outPage.Size.Height - font.Ascent * fontSize) / 2.0
            };

            // Move to position
            textgenerator.MoveTo(position);
            // Set text rendering 
            textgenerator.SetRendering(paint, null, false);
            // Add given stamp string
            textgenerator.ShowLine(stampString);
        }
        // Paint the positioned text
        gen.PaintText(text);
    }
}
Java sample:
// Open input document
inStream = new FileStream(inPath, "r");
inDoc = Document.open(inStream, null);

// Create output document
outStream = new FileStream(outPath, "rw");
outStream.setLength(0); 
outDoc = Document.create(outStream, Conformance.UNKNOWN, null);

// Create embedded font in output document
Font font = outDoc.createSystemFont("Arial", "Italic", true);

// Set output intent
if (inDoc.getOutputIntent() != null) 
    outDoc.setOutputIntent(outDoc.copyColorSpace(inDoc.getOutputIntent()));

// Copy metadata
Metadata metadata =  outDoc.copyMetadata(inDoc.getMetadata());
outDoc.setMetadata(metadata);

// Set copy options
EnumSet<CopyOption> copyOptions = EnumSet.of(CopyOption.COPY_LINKS, CopyOption.COPY_ANNOTATIONS,
        CopyOption.COPY_FORM_FIELDS, CopyOption.COPY_OUTLINES, CopyOption.COPY_LOGIGAL_STRUCTURE);

// Get the device color space
ColorSpace colorSpace = outDoc.createDeviceColorSpace(DeviceColorSpaceType.RGB);

// Choose the RGB color value
double[] color = {1.0, 0.0, 0.0};

// Create paint object
paint = outDoc.createAlphaPaint(colorSpace, alpha, color);

// Loop throw all pages of input
for (Page inPage : inDoc.getPages())
{
    // Copy page from input to output
    Page outPage = outDoc.copyPage(inPage, copyOptions);

    // Add text to page 
    addStamp(outDoc, outPage, stampString, font, 50);

    // Add page to document
    outDoc.getPages().add(outPage);

    //Cleanup
    outPage.close();
    inPage.close();
}
private static void addStamp(Document outputDoc, Page outPage, String stampString, 
Font font, double fontSize) throws ErrorCodeException 
{

    ContentGenerator generator = null;

    try 
    {
        // Create content generator 
        generator = new ContentGenerator(outPage.getContent(), false);

        // Create text object
        Text text = outputDoc.createText();

        // Create text generator
        TextGenerator textgenerator = new TextGenerator(text, font, fontSize, null);

        // Calculate point and angle of rotation
        Point rotationCenter = new Point(
                outPage.getSize().width / 2.0,
                outPage.getSize().height / 2.0
                );

        // Calculate rotation angle
        double rotationAngle = Math.atan2(outPage.getSize().height, 
            outPage.getSize().width) / Math.PI * 180.0;

        // Rotate text input around the calculated position
        Transformation trans = new Transformation();
        trans.rotateAround(rotationAngle, rotationCenter);
        generator.transform(trans);

        // Calculate position 
        Point position = new Point(
                (outPage.getSize().width - textgenerator.getWidth(stampString)) / 2.0,
                (outPage.getSize().height - font.getAscent() * fontSize) / 2.0
                );

        // Move to position 
        textgenerator.moveTo(position);

        // Set text rendering 
        textgenerator.setRendering(paint, null, false);

        // Add given stamp string 
        textgenerator.showLine(stampString);
        textgenerator.close(); 

        // Paint the positioned text
        generator.paintText(text);
    } 
    finally
    {
        // Close content generator
        if (generator != null)
            generator.close();
    }
}

Save time thanks to cloud-based PDF services

As the user base kept growing, more and more new functionalities were requested, such as compressing PDF files and converting office documents to PDF.

Smallpdf is a big hit when it comes to compression

Attaching a large file to an email can prevent it from being sent or received due to technical limitations. In order to solve this problem, the founders of Smallpdf searched for a way to reduce the size of these files. 

PDF Expert blog - the caveats of assembling PDF/A documents

The caveats of assembling PDF/A documents

Assembling PDF documents from various sources is a crucial part of an output management system. And, as the document needs to be archived in most cases, it should conform to the PDF/A standard. Is there a way to assemble a document and accomplish PDF/A conformance in one step?


PDF Expert Blog - embedded fonts and PDF mass printing application

The problem with embedded fonts in PDF mass printing applications

PDF is more and more finding its way into mass printing applications. However, PDF spool files often ask too much from a print engine resulting in aborts or, even worse, incomplete prints which may not be noticed. What is special about PDF mass printing...