/** **********************************************************************
 *
 * Copyright 2018 Jochen Staerk
 *
 * Use is subject to license terms.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy
 * of the License at http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *********************************************************************** */
package org.mustangproject.ZUGFeRD;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;

import jakarta.activation.DataSource;
import org.mustangproject.FileAttachment;

public interface IZUGFeRDExporter extends Closeable, IExporter {
	/**
	 * factory: loads a PDF file and returns an appropriate exporter
	 *
	 * @param pdfFilename binary of a PDF/A1 compliant document
	 * @return the generated exporter
	 * @throws IOException if anything is wrong with filename
	 */
	IZUGFeRDExporter load(String pdfFilename) throws IOException;

	/**
	 * Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
	 * metadata level, this will not e.g. convert graphics to JPG-2000)
	 *
	 * @param pdfBinary binary of a PDF/A1 compliant document
	 * @return the generated exporter
	 * @throws IOException (should not happen at all)
	 */
	IZUGFeRDExporter load(byte[] pdfBinary) throws IOException;

	/**
	 * Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
	 * metadata level, this will not e.g. convert graphics to JPG-2000)
	 *
	 * @param pdfSource source to read a PDF/A1 compliant document from
	 * @throws IOException if anything is wrong with inputstream
	 * @return the generated ZUGFeRDExporter
	 */
	IZUGFeRDExporter load(InputStream pdfSource) throws IOException;
	IZUGFeRDExporter setCreator(String creator); // sets the name of the author
	IZUGFeRDExporter setConformanceLevel(PDFAConformanceLevel newLevel);
	IZUGFeRDExporter setEnablePDFAttachmentCompression(boolean enablePDFAttachmentCompression);
	IZUGFeRDExporter setProducer(String producer); // set the PDF "producer"
	IZUGFeRDExporter setZUGFeRDVersion(int version);
	boolean ensurePDFIsValid(DataSource dataSource) throws IOException;
	IZUGFeRDExporter setXML(byte[] zugferdData) throws IOException;
	IZUGFeRDExporter disableFacturX();
	IZUGFeRDExporter setProfile(Profile zugferdConformanceLevel);
	String getNamespaceForVersion(int ver);
	String getPrefixForVersion(int ver) ;
	IZUGFeRDExporter disableAutoClose(boolean disableAutoClose);

	/***
	 * attach an additional PDF file attachment for Factur-X attachments
	 * (for attached files embedded into XML, within Germany domestically preferred,
	 * please refer to @see Invoice.embedFileInXML)
	 * @param file mime type and data
	 */
	void attachFile(FileAttachment file);

	/***
	 * attach an additional PDF file attachment for Factur-X attachments
	 * (for attached files embedded into XML, within Germany domestically preferred,
	 * please refer to @see Invoice.embedFileInXML
	 *
	 * @param filename the filename to be suggested
	 * @param data the binary data
	 * @param mimetype the mime type, from the list of allowed mime types
	 * @param relation the PDF relation
	 */
	void attachFile(String filename, byte[] data, String mimetype, String relation);

	IXMLProvider getProvider();

}
