All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ironsoftware.ironpdf.internal.staticapi.Metadata_Api Maven / Gradle / Ivy

Go to download

IronPDF Java library offers an extensive compatibility range, making it a go-to solution for a wide array of developers. It fully supports JVM languages like Java, Scala, and Kotlin, making it incredibly versatile. This Java PDF library is also compatible with Java 8 and above, providing optimum performance across multiple platforms. It's been designed with a wide range of users in mind Here's a look at what it supports: JVM Languages: Java, Scala, Kotlin.Platforms: Java 8 and above.Operating Systems: Microsoft Windows, Linux, Docker, Azure, AWS.IDEs: Jetbrains IntelliJ IDEA, Eclipse. You can deploy IronPDF Java across various platforms, including Microsoft Windows, Linux, Docker, Azure, and AWS. It is also fully compatible with popular IDEs like Jetbrains IntelliJ IDEA and Eclipse, facilitating smooth project development and management. Your pom.xml file is essentially the backbone of your project when you're using Maven. It's here where you introduce new dependencies that you wish to include. To make IronPDF Java package a part of your Maven project, you simply need to add the following snippets to your pom.xml: Remember to replace '20xx.xx.xxxx' with the latest version of IronPDF. IronPDF Java simplifies the process of creating PDF files. Convert HTML files, HTML strings, or URLs directly to new PDF documents in a few lines of code. The variety of file formats it handles is vast, as it can even transform images into PDF documents and vice versa. Need to use base 64 encoding, base URLs, or custom file paths? No problem! IronPDF Java has got you coveredFor more detail about installing and using IronPDF Java. When you run your project for the first time post-integration, IronPDF's engine binaries will automatically be downloaded. The engine starts its journey when you call any IronPDF function for the first time and takes a breather when your application is either closed or enters an idle state. It is not an open source java PDF library but here's the best part - IronPDF Java is offering a 30-day free trial. So, why wait? Give it a go and boost your PDF operations today.

There is a newer version: 2025.1.1
Show newest version
package com.ironsoftware.ironpdf.internal.staticapi;

import com.ironsoftware.ironpdf.internal.proto.*;

import static com.ironsoftware.ironpdf.internal.staticapi.Exception_Converter.fromProto;

/**
 * The type Metadata api.
 */
public final class Metadata_Api {

    /**
     * Gets the Author of the document.
     *
     * @param internalPdfDocument the internal pdf document
     * @return the author
     */
    public static String getAuthor(InternalPdfDocument internalPdfDocument) {
        return getMetadata(internalPdfDocument, "Author");
    }

    /**
     * Gets any metadata value of the document form given key.
     *
     * @param internalPdfDocument the internal pdf document
     * @param key                 the key
     * @return the metadata
     */
    public static String getMetadata(InternalPdfDocument internalPdfDocument, String key) {
        RpcClient client = Access.ensureConnection();

        PdfiumGetMetadataRequestP.Builder req = PdfiumGetMetadataRequestP.newBuilder();
        req.setDocument(internalPdfDocument.remoteDocument);
        req.setKey(key);
        PdfiumMetadataFieldResultP res = client.blockingStub.pdfiumMetadataGetMetadata(
                req.build());

        if (res.getResultOrExceptionCase() == PdfiumMetadataFieldResultP.ResultOrExceptionCase.EXCEPTION) {
            throw fromProto(res.getException());
        }

        return res.getResult().getValue();
    }

    /**
     * Sets the Author of the document.
     *
     * @param internalPdfDocument the internal pdf document
     * @param value               the value
     */
    public static void setAuthor(InternalPdfDocument internalPdfDocument, String value) {
        setMetadata(internalPdfDocument, "Author", value);
    }

    /**
     * Sets any metadata value of the document form given key.
     *
     * @param internalPdfDocument the internal pdf document
     * @param key                 the key
     * @param value               the value
     */
    public static void setMetadata(InternalPdfDocument internalPdfDocument, String key, String value) {
        RpcClient client = Access.ensureConnection();

        PdfiumSetMetadataRequestP.Builder req = PdfiumSetMetadataRequestP.newBuilder();
        req.setDocument(internalPdfDocument.remoteDocument);
        req.setKey(key);
        req.setValue(value);
        EmptyResultP res = client.blockingStub.pdfiumMetadataSetMetadata(req.build());
        Utils_Util.handleEmptyResult(res);
    }

    /**
     * Gets the PDF file creation DateTime.
     *
     * @param internalPdfDocument the internal pdf document
     * @return the creation date
     */
    public static String getCreationDate(InternalPdfDocument internalPdfDocument) {
        return getMetadata(internalPdfDocument, "CreationDate");
    }

    /**
     * Sets the PDF file creation DateTime.
     *
     * @param internalPdfDocument the internal pdf document
     * @param value               the value
     */
    public static void setCreationDate(InternalPdfDocument internalPdfDocument, String value) {
        setMetadata(internalPdfDocument, "CreationDate", value);
    }

    /**
     * Gets the PDF file last-modified DateTime.
     *
     * @param internalPdfDocument the internal pdf document
     * @return the modified date
     */
    public static String getModifiedDate(InternalPdfDocument internalPdfDocument) {
        return getMetadata(internalPdfDocument, "ModDate");
    }

    /**
     * Gets the PDF file last-modified DateTime.
     *
     * @param internalPdfDocument the internal pdf document
     * @param value               the value
     */
    public static void setModifiedDate(InternalPdfDocument internalPdfDocument, String value) {
        setMetadata(internalPdfDocument, "ModDate", value);
    }

    /**
     * Gets the Creator of the document.
     *
     * @param internalPdfDocument the internal pdf document
     * @return the creator
     */
    public static String getCreator(InternalPdfDocument internalPdfDocument) {
        return getMetadata(internalPdfDocument, "Creator");
    }

    /**
     * Sets the Creator of the document.
     *
     * @param internalPdfDocument the internal pdf document
     * @param value               the value
     */
    public static void setCreator(InternalPdfDocument internalPdfDocument, String value) {
        setMetadata(internalPdfDocument, "Creator", value);
    }

    /**
     * Gets Keywords of the document.  This helps search indexes and operating systems correctly index
     * the PDF.
     *
     * @param internalPdfDocument the internal pdf document
     * @return the keywords
     */
    public static String getKeywords(InternalPdfDocument internalPdfDocument) {
        return getMetadata(internalPdfDocument, "Keywords");
    }

    /**
     * Sets Keywords of the document.  This helps search indexes and operating systems correctly index
     * the PDF.
     *
     * @param internalPdfDocument the internal pdf document
     * @param value               the value
     */
    public static void setKeywords(InternalPdfDocument internalPdfDocument, String value) {
        setMetadata(internalPdfDocument, "Keywords", value);
    }

    /**
     * Gets the Producer of the document.
     *
     * @param internalPdfDocument the internal pdf document
     * @return the producer
     */
    public static String getProducer(InternalPdfDocument internalPdfDocument) {
        return getMetadata(internalPdfDocument, "Producer");
    }

    /**
     * Sets the Producer of the document.
     *
     * @param internalPdfDocument the internal pdf document
     * @param value               the value
     */
    public static void setProducer(InternalPdfDocument internalPdfDocument, String value) {
        setMetadata(internalPdfDocument, "Producer", value);
    }

    /**
     * Gets Subject of the document.  This helps search indexes and operating systems correctly index
     * the PDF, and may appear in PDF viewer software.
     *
     * @param internalPdfDocument the internal pdf document
     * @return the subject
     */
    public static String getSubject(InternalPdfDocument internalPdfDocument) {
        return getMetadata(internalPdfDocument, "Subject");
    }

    /**
     * Sets the Subject of the document.  This helps search indexes and operating systems correctly
     * index the PDF, and may appear in PDF viewer software.
     *
     * @param internalPdfDocument the internal pdf document
     * @param value               the value
     */
    public static void setSubject(InternalPdfDocument internalPdfDocument, String value) {
        setMetadata(internalPdfDocument, "Subject", value);
    }

    /**
     * Gets the Title of the document.  This helps search indexes and operating systems correctly
     * index the PDF, and may appear in PDF viewer software.
     *
     * @param internalPdfDocument the internal pdf document
     * @return the title
     */
    public static String getTitle(InternalPdfDocument internalPdfDocument) {
        return getMetadata(internalPdfDocument, "Title");
    }

    /**
     * Sets the Title of the document.  This helps search indexes and operating systems correctly
     * index the PDF, and may appear in PDF viewer software.
     *
     * @param internalPdfDocument the internal pdf document
     * @param value               the value
     */
    public static void setTitle(InternalPdfDocument internalPdfDocument, String value) {
        setMetadata(internalPdfDocument, "Title", value);
    }

    /**
     * Method for removing Metadata property by its name.
     *
     * @param internalPdfDocument the internal pdf document
     * @param key                 The name of the property.
     */
    public static void removeMetadata(InternalPdfDocument internalPdfDocument, String key) {
        RpcClient client = Access.ensureConnection();

        PdfiumRemoveMetadataRequestP.Builder req = PdfiumRemoveMetadataRequestP.newBuilder();
        req.setDocument(internalPdfDocument.remoteDocument);
        req.setKey(key);
        EmptyResultP res = client.blockingStub.pdfiumMetadataRemoveMetadata(req.build());
        Utils_Util.handleEmptyResult(res);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy