use of com.asprise.imaging.core.Imaging in project arquivoProject by fader-azevedo.
the class CriarPautaController method scan.
@FXML
private void scan() throws IOException, DocumentException {
int numPDF = 20;
PdfReader[] pdfArray = new PdfReader[numPDF];
DBConnector gerrarPDF = new DBConnector(pdfArray);
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Por favor confirma");
alert.setHeaderText("Desejas Scannear mais uma pagina dessa Pauta?");
alert.setContentText("Caso sim, põe a página no scan!");
((Button) alert.getDialogPane().lookupButton(ButtonType.OK)).setText("Sim");
((Button) alert.getDialogPane().lookupButton(ButtonType.CANCEL)).setText("Não");
// array que vai possibilitar a remocao de pdf
String[] arrayFiles = new String[numPDF];
// array que vai possibilitar a remocao de pdf
int index = 0;
do {
Imaging imaging = new Imaging("myApp", 0);
Result result = imaging.scan(Request.fromJson("{" + "\"output_settings\" : [ {" + " \"type\" : \"save\"," + " \"format\" : \"pdf\"," + " \"save_path\" : \"documentos/pautas\\\\${TMS}${EXT}\"" + "} ]" + "}"), "select", false, false);
// salva o doc
if (result == null) {
return;
}
// formatcao do caminho
String url = result.getPdfFile().getPath().replace("\\", "/");
// busca o doc que acaba de ser guardado
PdfReader pdf = new PdfReader(url);
// preeche o array com a foto salva
gerrarPDF.preecherArrayPDF(pdf);
arrayFiles[index] = url;
index++;
} while (alert.showAndWait().get() == javafx.scene.control.ButtonType.OK);
iconCheck.setVisible(true);
btnScan.setDisable(true);
Calendar cal = Calendar.getInstance();
pdfNome = "pauta_" + new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(cal.getTime());
String pdfCaminho = gerrarPDF.gerrarPDFPauta(pdfNome);
/*ciclo de remocao*/
for (String arrayFile : arrayFiles) {
if (arrayFile != null) {
File f = new File(arrayFile);
f.delete();
}
}
FXMLLoader loader = new FXMLLoader();
loader.load(getClass().getResource("/view/PdfViewer.fxml").openStream());
Parent parent = loader.getRoot();
PdfViewerController pdfController = loader.getController();
pdfController.initialize();
pdfController.loadFile(pdfCaminho);
final Stage dialog = new Stage();
dialog.initModality(Modality.APPLICATION_MODAL);
Scene dialogScene = new Scene(parent, 500, 620);
dialog.setScene(dialogScene);
dialog.setTitle("Resultado de Scan");
dialog.setResizable(false);
dialog.show();
}
Aggregations