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

com.itextpdf.pdfa.PdfAXMPUtil Maven / Gradle / Ivy

/*
    This file is part of the iText (R) project.
    Copyright (c) 1998-2024 Apryse Group NV
    Authors: Apryse Software.

    This program is offered under a commercial and under the AGPL license.
    For commercial licensing, contact us at https://itextpdf.com/sales.  For AGPL licensing, see below.

    AGPL licensing:
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see .
 */
package com.itextpdf.pdfa;

import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.StandardCharsets;

/**
 * Utilities to construct an XMP for a PDF/A file.
 */
public class PdfAXMPUtil {

    public static final String PDF_UA_EXTENSION =
            "    \n" +
                    "      \n" +
                    "        \n" +
                    "          \n" +
                    "            \n" +
                    "              \n" +
                    "                \n" +
                    "                pdfuaid\n" +
                    "                PDF/UA identification schema\n" +
                    "                \n" +
                    "                  \n" +
                    "                    \n" +
                    "                      internal\n" +
                    "                      PDF/UA version identifier\n" +
                    "                      part\n" +
                    "                      Integer\n" +
                    "                    \n" +
                    "                    \n" +
                    "                      internal\n" +
                    "                      PDF/UA amendment identifier\n" +
                    "                      amd\n" +
                    "                      Text\n" +
                    "                    \n" +
                    "                    \n" +
                    "                      internal\n" +
                    "                      PDF/UA corrigenda identifier\n" +
                    "                      corr\n" +
                    "                      Text\n" +
                    "                    \n" +
                    "                  \n" +
                    "                \n" +
                    "              \n" +
                    "            \n" +
                    "          \n" +
                    "        \n" +
                    "      \n" +
                    "    ";

    /**
     * Check whether the given byte array is an UTF-8 encoded character sequence.
     *
     * @param array array to check
     *
     * @return true if array is UTF-8 encoded data, false otherwise
     */
    public static boolean isUtf8(byte[] array) {
        try {
            StandardCharsets.UTF_8.newDecoder().decode(ByteBuffer.wrap(array));
        }
        catch (CharacterCodingException e) {
            return false;
        }
        return true;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy