class PdfVersionImp implements PdfVersion {

    /**
     * Contains different strings that are part of the header.
     */
    public static final byte[][] HEADER = {
            DocWriter.getISOBytes("\n"),
            DocWriter.getISOBytes("%PDF-"),
            DocWriter.getISOBytes("\n%\u00e2\u00e3\u00cf\u00d3\n")
    };

    /**
     * Indicates if the header was already written.
     */
    protected boolean headerWasWritten = false;
    /**
     * Indicates if we are working in append mode.
     */
    protected boolean appendmode = false;
    /**
     * The version that was or will be written to the header.
     */
    protected char header_version = PdfWriter.VERSION_1_5;
    /**
     * The version that will be written to the catalog.
     */
    protected PdfName catalog_version = null;
    /**
     * The extensions dictionary.
     *
     * @since 2.1.6
     */
    protected PdfDictionary extensions = null;

    /**
     * @see com.lowagie.text.pdf.interfaces.PdfVersion#setPdfVersion(char)
     */
    public void setPdfVersion(char version) {
        if (headerWasWritten || appendmode) {
            setPdfVersion(getVersionAsName(version));
        } else {
            this.header_version = version;
        }
    }

    /**
     * @see com.lowagie.text.pdf.interfaces.PdfVersion#setAtLeastPdfVersion(char)
     */
    public void setAtLeastPdfVersion(char version) {
        if (version > header_version) {
            setPdfVersion(version);
        }
    }

    /**
     * @see com.lowagie.text.pdf.interfaces.PdfVersion#setPdfVersion(com.lowagie.text.pdf.PdfName)
     */
    public void setPdfVersion(PdfName version) {
        if (catalog_version == null || catalog_version.compareTo(version) < 0) {
            this.catalog_version = version;
        }
    }

    /**
     * Sets the append mode.
     *
     * @param appendmode Boolean that indicates if we are working in append mode.
     */
    public void setAppendmode(boolean appendmode) {
        this.appendmode = appendmode;
    }

    /**
     * Writes the header to the OutputStreamCounter.
     *
     * @param os the OutputStreamCounter
     * @throws IOException thrown when an I/O operation goes wrong
     */
    public void writeHeader(OutputStreamCounter os) throws IOException {
        if (appendmode) {
            os.write(HEADER[0]);
        } else {
            os.write(HEADER[1]);
            os.write(getVersionAsByteArray(header_version));
            os.write(HEADER[2]);
            headerWasWritten = true;
        }
    }

    /**
     * Returns the PDF version as a name.
     *
     * @param version the version character.
     * @return a PdfName that contains the version
     */
    public PdfName getVersionAsName(char version) {
        switch (version) {
            case PdfWriter.VERSION_1_2:
                return PdfWriter.PDF_VERSION_1_2;
            case PdfWriter.VERSION_1_3:
                return PdfWriter.PDF_VERSION_1_3;
            case PdfWriter.VERSION_1_4:
                return PdfWriter.PDF_VERSION_1_4;
            case PdfWriter.VERSION_1_5:
                return PdfWriter.PDF_VERSION_1_5;
            case PdfWriter.VERSION_1_6:
                return PdfWriter.PDF_VERSION_1_6;
            case PdfWriter.VERSION_1_7:
                return PdfWriter.PDF_VERSION_1_7;
            default:
                return PdfWriter.PDF_VERSION_1_4;
        }
    }

    /**
     * Returns the version as a byte[].
     *
     * @param version the version character
     * @return a byte array containing the version according to the ISO-8859-1 codepage.
     */
    public byte[] getVersionAsByteArray(char version) {
        return DocWriter.getISOBytes(getVersionAsName(version).toString().substring(1));
    }

    /**
     * Adds the version to the Catalog dictionary.
     *
     * @param catalog The PdfDictionary to add the version to
     */
    public void addToCatalog(PdfDictionary catalog) {<FILL_FUNCTION_BODY>}

    /**
     * @see com.lowagie.text.pdf.interfaces.PdfVersion#addDeveloperExtension(com.lowagie.text.pdf.PdfDeveloperExtension)
     * @since 2.1.6
     */
    public void addDeveloperExtension(PdfDeveloperExtension de) {
        if (extensions == null) {
            extensions = new PdfDictionary();
        } else {
            PdfDictionary extension = extensions.getAsDict(de.getPrefix());
            if (extension != null) {
                int diff = de.getBaseversion().compareTo(extension.getAsName(PdfName.BASEVERSION));
                if (diff < 0) {
                    return;
                }
                diff = de.getExtensionLevel() - extension.getAsNumber(PdfName.EXTENSIONLEVEL).intValue();
                if (diff <= 0) {
                    return;
                }
            }
        }
        extensions.put(de.getPrefix(), de.getDeveloperExtensions());
    }
}

        if (catalog_version != null) {
            catalog.put(PdfName.VERSION, catalog_version);
        }
        if (extensions != null) {
            catalog.put(PdfName.EXTENSIONS, extensions);
        }
    
<no_super_class>