1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| package main;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import com.artofsolving.jodconverter.openoffice.connection.*;
import com.artofsolving.jodconverter.openoffice.converter.*;
import com.artofsolving.jodconverter.*;
public class PdfToPDF1A {
public static void main(String[] args) throws Exception {
// Link to OpenOffice.org, which needs to be running as a service in the background
OpenOfficeConnection OOconnection = new SocketOpenOfficeConnection(8100);
OOconnection.connect();
File outFile = new File("D:/Java/eclipse/workspace/SigedisPDF/data/DOC/Test word.pdf");
File pdfA1File = new File("D:/Java/eclipse/workspace/SigedisPDF/data/DOC/Test word A1.pdf");
DocumentFormat inputPdfFormat = new DocumentFormat("Portable Document Format", DocumentFamily.DRAWING, "application/pdf", "pdf");
DocumentFormat outputPdfFormat = new DocumentFormat("Portable Document Format", "application/pdf", "pdf");
outputPdfFormat.setExportFilter(DocumentFamily.DRAWING,"draw_pdf_Export");
Map<String,Object> pdfOptions = new HashMap<String,Object>();
pdfOptions.put("SelectPdfVersion", Integer.valueOf(1));
outputPdfFormat.setExportOption(DocumentFamily.DRAWING, "FilterData", pdfOptions);
// do the conversion
DocumentConverter PDFconverter = new OpenOfficeDocumentConverter(OOconnection);
PDFconverter.convert(outFile, inputPdfFormat, pdfA1File,outputPdfFormat);
//PDFconverter.convert(inFile, pdfA1File,toFormatPDFA());
OOconnection.disconnect();
}
} |
Partager