Search in sources :

Example 1 with Result

use of com.asprise.imaging.core.Result 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();
}
Also used : Parent(javafx.scene.Parent) Calendar(java.util.Calendar) PdfReader(com.lowagie.text.pdf.PdfReader) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) Result(com.asprise.imaging.core.Result) Button(javafx.scene.control.Button) JFXButton(com.jfoenix.controls.JFXButton) Imaging(com.asprise.imaging.core.Imaging) Stage(javafx.stage.Stage) Alert(javafx.scene.control.Alert) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) FXML(javafx.fxml.FXML)

Aggregations

Imaging (com.asprise.imaging.core.Imaging)1 Result (com.asprise.imaging.core.Result)1 JFXButton (com.jfoenix.controls.JFXButton)1 PdfReader (com.lowagie.text.pdf.PdfReader)1 File (java.io.File)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 FXML (javafx.fxml.FXML)1 FXMLLoader (javafx.fxml.FXMLLoader)1 Parent (javafx.scene.Parent)1 Scene (javafx.scene.Scene)1 Alert (javafx.scene.control.Alert)1 Button (javafx.scene.control.Button)1 Stage (javafx.stage.Stage)1