Difference between revisions of "Cognitive PDF/A"
From OpenKM Documentation
m |
|||
(11 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | [http://cognitiveforms.com/esp/products_and_services/Cognititive_PDF/A.html#555-A Cognitive PDF/A] is a powerful [http://cognitiveforms.com Cognitive Forms] tool which it makes PDF/A ISO standard documents from scanned document images. OpenKM integrate Compressimo transparently using automation or crontab utilities. | |
Description: | Description: | ||
* Input server folder where images are stored '''systemFolder = "c:\\samples"''' | * Input server folder where images are stored '''systemFolder = "c:\\samples"''' | ||
− | * | + | * Cognitive PDF/A server path '''cognitivePdfa''' |
* OpenKM path where compressimo files are imported '''String path = "/okm:root/imported" + "/" + uploadFile.getName()''' | * OpenKM path where compressimo files are imported '''String path = "/okm:root/imported" + "/" + uploadFile.getName()''' | ||
Line 17: | Line 17: | ||
String token = DbSessionManager.getInstance().getSystemToken(); | String token = DbSessionManager.getInstance().getSystemToken(); | ||
String systemFolder = "c:\\samples"; | String systemFolder = "c:\\samples"; | ||
− | String | + | String cognitivePdfa = "C:\\Users\\jllort\\Desktop\\cpdfa-1.4.4-dev-win32-1month\\cpdfa\\bin\\cpdfacli.exe splitdummy eng "; |
Logger log = LoggerFactory.getLogger("com.openkm.compressimo"); | Logger log = LoggerFactory.getLogger("com.openkm.compressimo"); | ||
Line 24: | Line 24: | ||
File folder = new File(systemFolder); | File folder = new File(systemFolder); | ||
File[] listOfFiles = folder.listFiles(); | File[] listOfFiles = folder.listFiles(); | ||
+ | |||
for (int i=0; i<listOfFiles.length; i++) { | for (int i=0; i<listOfFiles.length; i++) { | ||
File file = listOfFiles[i]; | File file = listOfFiles[i]; | ||
+ | |||
if (file.isFile() && file.getName().toLowerCase().endsWith(".tif")) { | if (file.isFile() && file.getName().toLowerCase().endsWith(".tif")) { | ||
− | |||
// Converting tif file to pdf | // Converting tif file to pdf | ||
String tifFile = systemFolder + "\\" + file.getName(); | String tifFile = systemFolder + "\\" + file.getName(); | ||
− | String pdfFile = systemFolder + "\\" + file.getName().toLowerCase().replace(".tif",".pdf"); | + | String pdfFile = systemFolder + "\\" + file.getName().toLowerCase().replace(".tif", ".pdf"); |
log.info("Converting file:" + tifFile+" to:"+pdfFile); | log.info("Converting file:" + tifFile+" to:"+pdfFile); | ||
− | String command = | + | String command = cognitivePdfa + tifFile + " " + pdfFile; |
Process process = Runtime.getRuntime().exec(command); | Process process = Runtime.getRuntime().exec(command); | ||
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); | BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); | ||
String line = null; | String line = null; | ||
− | while ((line=input.readLine())!=null) { | + | |
+ | while ((line=input.readLine()) != null) { | ||
log.info(line); | log.info(line); | ||
} | } | ||
+ | |||
int exitVal = process.waitFor(); | int exitVal = process.waitFor(); | ||
log.info("Exit code " + exitVal); | log.info("Exit code " + exitVal); | ||
Line 56: | Line 59: | ||
} | } | ||
} | } | ||
+ | |||
log.info("***** Process END *****"); | log.info("***** Process END *****"); | ||
</source> | </source> | ||
+ | |||
+ | == Example == | ||
+ | '''Scanned files:''' | ||
+ | Red square remark initial document size. | ||
+ | [[File:Okm_user_guide_360.png|center]] | ||
+ | |||
+ | |||
+ | '''Crontab compressimo importer task:''' | ||
+ | [[File:Okm_user_guide_361.png|center]] | ||
+ | |||
+ | |||
+ | '''OpenKM log execution server output:''' | ||
+ | [[File:Okm_user_guide_362.png|center|900px]] | ||
+ | |||
+ | |||
+ | '''Imported files:''' | ||
+ | Red square remark final document size. | ||
+ | [[File:Okm_user_guide_363.png|center]] | ||
+ | |||
+ | |||
+ | '''PDF/A compliance:''' | ||
+ | [[File:Okm_user_guide_364.png|center]] | ||
+ | |||
+ | |||
+ | '''Search engine search by content:''' | ||
+ | [[File:Okm_user_guide_365.png|center]] | ||
+ | |||
For more information: | For more information: | ||
− | * | + | * [http://cognitiveforms.com/assets/files/cpdfas.pdf Cognitive PDF/A documentation] |
− | * | + | * [http://cognitiveforms.com/esp/products_and_services/Cognititive_PDF/A.html#555-A Cognitive PDF/A website] |
− | * | + | * [http://cognitiveforms.com Cognitive Forms] |
[[Category: Utilities]] | [[Category: Utilities]] |
Latest revision as of 13:42, 11 February 2013
Cognitive PDF/A is a powerful Cognitive Forms tool which it makes PDF/A ISO standard documents from scanned document images. OpenKM integrate Compressimo transparently using automation or crontab utilities.
Description:
- Input server folder where images are stored systemFolder = "c:\\samples"
- Cognitive PDF/A server path cognitivePdfa
- OpenKM path where compressimo files are imported String path = "/okm:root/imported" + "/" + uploadFile.getName()
import java.io.*;
import java.util.*;
import com.openkm.module.db.stuff.DbSessionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.openkm.bean.Document;
import com.openkm.api.OKMDocument;
String token = DbSessionManager.getInstance().getSystemToken();
String systemFolder = "c:\\samples";
String cognitivePdfa = "C:\\Users\\jllort\\Desktop\\cpdfa-1.4.4-dev-win32-1month\\cpdfa\\bin\\cpdfacli.exe splitdummy eng ";
Logger log = LoggerFactory.getLogger("com.openkm.compressimo");
// Loading files
log.info("***** Process BEGIN *****");
File folder = new File(systemFolder);
File[] listOfFiles = folder.listFiles();
for (int i=0; i<listOfFiles.length; i++) {
File file = listOfFiles[i];
if (file.isFile() && file.getName().toLowerCase().endsWith(".tif")) {
// Converting tif file to pdf
String tifFile = systemFolder + "\\" + file.getName();
String pdfFile = systemFolder + "\\" + file.getName().toLowerCase().replace(".tif", ".pdf");
log.info("Converting file:" + tifFile+" to:"+pdfFile);
String command = cognitivePdfa + tifFile + " " + pdfFile;
Process process = Runtime.getRuntime().exec(command);
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
while ((line=input.readLine()) != null) {
log.info(line);
}
int exitVal = process.waitFor();
log.info("Exit code " + exitVal);
// Uploading pdf file
File uploadFile = new File(pdfFile);
Document doc = new Document();
String path = "/okm:root/imported" + "/" + uploadFile.getName();
log.info("Importing file:"+ pdfFile + " to:"+path);
doc.setPath(path);
FileInputStream fis = new FileInputStream(uploadFile);
doc = OKMDocument.getInstance().create(token, doc, fis);
// Deleting pdf File
uploadFile.delete();
}
}
log.info("***** Process END *****");
Example
Scanned files: Red square remark initial document size.
Crontab compressimo importer task:
OpenKM log execution server output:
Imported files:
Red square remark final document size.
PDF/A compliance:
Search engine search by content:
For more information: