Nuclos FileProvider: print, save, newFile, NuclosFile, printer, output format, byte[]. |
Language: Deutsch · English
Print, save and create NuclosFiles from byte arrays.
On this page |
The FileProvider contains methods to process NuclosFiles – printing, saving on the server and converting.
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. |
Sends the NuclosFile to the default or a named printer.
public static void print(NuclosFile file) throws BusinessException; public static void print(NuclosFile file, String printername) throws BusinessException; |
Saves the NuclosFile on the server in the given directory.
public static void save(NuclosFile file, String directory) throws BusinessException; |
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);
}
} |
Use FileProvider.newFile(File) to turn a byte array into a NuclosFile:
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());
}
} |