### Run the documents4j local demo Source: https://documents4j.com/ Commands to clone and start the local demonstration application using Maven. ```bash 1. git clone https://github.com/documents4j/documents4j.git 2. cd documents4j 3. cd documents4j-local-demo 4. mvn jetty:run ``` -------------------------------- ### Start the standalone conversion server Source: https://documents4j.com/ Command to launch the standalone conversion server JAR, specifying the listening port. ```bash 1. java -jar documents4j-server-standalone-shaded.jar http://localhost:9998 ``` -------------------------------- ### Run Documents4j Server with SSL Source: https://documents4j.com/ Start the standalone documents4j server with SSL enabled, specifying the keystore path and password. The -ssl flag enables SSL, and system properties configure the keystore. ```bash java -jar documents4j-client-standalone--shaded.jar https://0.0.0.0:8443 -ssl -Djavax.net.ssl.keyStore=/path/to/your/keystore -Djavax.net.ssl.keyStorePassword=yourPassword ``` -------------------------------- ### Connect using the conversion client Source: https://documents4j.com/ Command to connect the standalone console client to a running conversion server for validation. ```bash 1. java -jar documents4j-client-standalone-shaded.jar http://localhost:9998 ``` -------------------------------- ### Initialize LocalConverter with Builder Source: https://documents4j.com/ Configures a LocalConverter instance with a base folder, worker pool settings, and process timeout. ```java 1. IConverter converter = LocalConverter.builder() 2. .baseFolder(new File("C:\Users\documents4j\temp")); 3. .workerPool(20, 25, 2, TimeUnit.SECONDS) 4. .processTimeout(5, TimeUnit.SECONDS) 5. .build(); ``` -------------------------------- ### Generate Keystore for SSL Source: https://documents4j.com/ Use openssl to export a certificate and key into a PKCS12 file, then import it into a Java keystore. Requires a password for both operations. ```bash openssl pkcs12 -export -in /path/to/your/cert.crt -inkey /path/to/your/cert.key -name serverCert -out /tmp/keystore-PKCS-12.p12 -password pass:yourPassword ``` ```bash keytool -importkeystore -noprompt -deststorepass yourPassword -srcstorepass yourPassword -destkeystore /path/to/your/keystore -srckeystore /tmp/keystore-PKCS-12.p12 ``` -------------------------------- ### Create a RemoteConverter instance Source: https://documents4j.com/ Configures a RemoteConverter using the builder pattern, specifying base folder, worker pool, timeouts, and the conversion server URI. ```java 1. IConverter converter = RemoteConverter.builder() 2. .baseFolder(new File("C:\Users\documents4j\temp")); 3. .workerPool(20, 25, 2, TimeUnit.SECONDS) 4. .requestTimeout(10, TimeUnit.SECONDS) 5. .baseUri("http://localhost:9998"); 6. .build(); ``` -------------------------------- ### Create an AggregatingConverter Source: https://documents4j.com/ Build an IAggregatingConverter using a builder pattern. This allows aggregation of multiple converters, custom selection strategies, and failure callbacks. ```java IConverter first = ... , second = ... ; IConverterFailureCallback converterFailureCallback = ... ; ISelectionStrategy selectionStrategy = ... ; IAggregatingConverter converter = AggregatingConverter.builder() .aggregates(first, second) .selectionStrategy(selectionStrategy) .callback(converterFailureCallback) .build(); ``` -------------------------------- ### Perform Document Conversion Source: https://documents4j.com/ Use this snippet to convert a document from one format to another. Specify input and output files, document types, and optionally set a priority for the conversion. The conversion is scheduled to run in the background. ```java 1. File wordFile = new File( ... ), target = new File( ... ); 2. IConverter converter = ... ; 3. Future conversion = converter 4. .convert(wordFile).as(DocumentType.MS_WORD) 5. .to(target).as(DocumentType.PDF) 6. .prioritizeWith(1000) // optional 7. .schedule(); ``` -------------------------------- ### Terminate zombie MS Office processes via batch script Source: https://documents4j.com/ Use this script to clean up orphaned wscript.exe and winword.exe processes. Ensure this runs during idle times as it will terminate active conversions. ```batch 1. taskkill /f /t /im wscript.exe 2. taskkill /f /t /im winword.exe ``` -------------------------------- ### Close hung MS Office windows via batch script Source: https://documents4j.com/ Use this script in a Windows task scheduler to periodically terminate MS Office windows that report conversion failures. ```batch 1. taskkill /F /FI "WindowTitle eq Microsoft Word*" 2. taskkill /F /FI "WindowTitle eq Microsoft Office*" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.