Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.
Auszug
hiddentrue

Nuclos FileProvider: print, save, newFile, NuclosFile, printer, output format, byte[].

globe with meridians Language: Deutsch · English

open book FileProvider

Print, save and create NuclosFiles from byte arrays.

Status
colourGrey
titleReferenz
Status
colourBlue
titleDeveloper
Status
colourGreen
titleUpdated: Jul 2026
Status
colourGrey
titleapplies to Nuclos 4.2026.x

Panel
bgColor#F4F5F7

On this page

Inhalt
maxLevel2
minLevel2

What is the FileProvider for?

The FileProvider contains methods to process NuclosFiles – printing, saving on the server and converting.

Info
titleOutput formats

Only NuclosFiles in the output format File or Screen can be stored as attachments. For the printer the format (default) printer client/server is required – possibly two output formats per report/form.

print(file[, printername])

Sends the NuclosFile to the default or a named printer.

Codeblock
languagejava
public static void print(NuclosFile file) throws BusinessException;
public static void print(NuclosFile file, String printername) throws BusinessException;

save(file, directory)

Saves the NuclosFile on the server in the given directory.

Codeblock
languagejava
public static void save(NuclosFile file, String directory) throws BusinessException;
Codeblock
languagejava
package org.nuclet.businessentity; 

import org.nuclet.printout.FormularAbschlussAuftragPO;
import org.nuclos.api.common.NuclosFile;
import org.nuclos.api.provider.PrintoutProvider;
import org.nuclos.api.provider.FileProvider;

public class AbschlussAuftragRegel implements InsertFinalRule {

   public void insertFinal(InsertContext context) throws BusinessException { 
        
		Auftrag a = context.getBusinessObject(Auftrag.class);
      	
		NuclosFile result = PrintoutProvider.run(FormularAbschlussAuftragPO.Deutsch_PDF, a.getId());
        
		// store file in FTP-Directory
		FileProvider.save(result, "/home/ftp/");
		// Print file on default printer
        FileProvider.print(result);
    }
}

Convert byte[] to NuclosFile

Use FileProvider.newFile(File) to turn a byte array into a NuclosFile:

Codeblock
languagejava
public static NuclosFile writeArrayToNuclosFile(String filename, byte[] content) throws BusinessException {
    File file = null;
    try {
        file = new File(filename);
        FileUtils.writeByteArrayToFile(file, content);
        return FileProvider.newFile(file);
    } catch (IOException exception) {
        throw new BusinessException("Fehler beim Erzeugen der Datei " + file.getName() + ": " + exception.getMessage());
    }
}

Related pages

gear QueryProvider


Daten laden.

Open →

gear BusinessObjectProvider


BOs schreiben.

Open →

gear DatasourceProvider


run data sources.

Open →