Code Monkey home page Code Monkey logo

jodconverter's Introduction

  LibreOffice / Apache OpenOffice

Build Status Coverage Status Codacy Badge License Maven Central Javadocs Join the chat at https://gitter.im/jodconverter/Lobby Donate

What you want to know...

  • Documentation: The JODConverter documentation (work in progress) can be found here.
  • Examples: A dedicated repository with sample projects can be found here.
  • Dependencies:
  • Tests: JODConverter is supposed to work just fine on recent versions of Windows, MacOS and Unix/Linux. Any confirmation would be welcome, so we could build a list of official supported OS distributions.

Usage for local conversions

Build default, JODConverter is built using the OpenOffice libraries. See here to know why. But you can now decide whether you want to use JODConverter with the LibreOffice libraries or the OpenOffice libraries.

With LibreOffice libraries:

Gradle:

implementation 'org.jodconverter:jodconverter-local-lo:4.4.7'

Maven:

<dependency>
  <groupId>org.jodconverter</groupId>
  <artifactId>jodconverter-local-lo</artifactId>
  <version>4.4.7</version>
</dependency>

With OpenOffice libraries:

Gradle:

implementation 'org.jodconverter:jodconverter-local:4.4.7'

or

implementation 'org.jodconverter:jodconverter-local-oo:4.4.7'

Maven:

<dependency>
  <groupId>org.jodconverter</groupId>
  <artifactId>jodconverter-local</artifactId>
  <version>4.4.7</version>
</dependency>

or

<dependency>
  <groupId>org.jodconverter</groupId>
  <artifactId>jodconverter-local-oo</artifactId>
  <version>4.4.7</version>
</dependency>

Building the Project

gradlew clean build -x test

Building Cli Executable

gradlew clean build -x test distZip

Support 💬

JODConverter Gitter Community Join the chat at https://gitter.im/jodconverter/Lobby, growing FAQ.

How to contribute

  1. Check for open issues, or open a new issue to start a discussion around a feature idea or a bug.
  2. If you feel uncomfortable or uncertain about an issue or your changes, feel free to contact me on Gitter using the link above.
  3. Fork this repository on GitHub to start making your changes.
  4. Write a test showing that the bug was fixed or that the feature works as expected.
  5. Note that the repository follows the Google Java style. You can format your code to this format by typing gradlew spotlessApply on the subproject you work on (e.g, gradlew :jodconverter-local:spotlessApply), by using the Eclipse plugin, or by using the Intellij plugin.
  6. Create a pull request, and wait until it gets merged and published.

Credits...

Here are my favorite/inspiration forks/projects:

  • documents4j project: Nice choice if you want 100% perfect conversion using MS Office. But work only on Windows out of the box (Local implementation) and not totally free (since MS Office is not free). The new "job" package is strongly inspired by this project.

Original JODConverter

JODConverter (Java OpenDocument Converter) automates document conversions using LibreOffice or OpenOffice.org.

The previous home for this project is at Google Code, including some wiki pages.

Donations

If this project helps you, please consider a cup of ☕. Thanks!! ❤️

paypal

jodconverter's People

Contributors

alexey-atiskov avatar aruis avatar bianjp avatar caolanm avatar chunlinyao avatar eugenmayer avatar gitter-badger avatar is-simon avatar jgoldhammer avatar joseluisll avatar liammacp avatar linux-warrior avatar michelole avatar mirkonasato avatar nikowitt avatar qiangtoudianyan avatar recurve avatar sbraconnier avatar shysteph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jodconverter's Issues

Use TableOfContentUpdaterFilter in Spring Boot

Hi,

I'm having troubles that DOCX ToC are updated when generating PDFs in my Spring Boot Service. So I stumbled across this closed issue, where TableOfContentUpdaterFilter was introduced. But I'm not sure how to configure it when using the Spring Boot Starter. The autowired DocumentConverter can only be influenced by the properties, but I don't see a property for filters. Do I need to dump the spring libraries and use jodconverter directly, or am I missing something here?

Thanks in advance for your answers.

LibreOffice Portable support for Windows

We recently switched to LibreOffice Portable to easily distribute LibreOffice with our software. Now I realized that LibreOffice Portable works a little differently. Therefore I took your source and started to modify it for the support. However, I am sure I do it a bit too much quick and dirty. If I told you what the significant differences are, could you help me to find the places where I should apply those changes to contribute back to you?

The differences are:

  • You need to start LibreOfficePortable from the LibreOfficePortable.exe (that can be solved by somehow detecting that the officepath is within a libreofficeportable, then it uses a different executable path which points to the LibreOfficePortable.exe)
  • On close, it is important that the JODConverter does not close the LibreOfficePortable.exe, since that is only a wrapper. So it needs to close a different process than the one it opened, which is either the soffice.exe or the soffice.bin (the soffice.bin seems to work better, but we did not test that extensively yet).

Edit: THIS IS NOT REQUIRED, DO NOT INCLUDE INTO DOCUMENTATION.

Warning: Office process died with exit code 81; restarting it

  1. If I don't start libreoffice process manually (I used default port in code), jodconverter can convert file but writes warning to console:
    Warning: Office process died with exit code 81; restarting it
    Every time when I convert file I see above warning. So jodconverter starts libreoffice with default 2002 port and can convert file, but there is warning. I understand that libreoffice has not been started but 1st time warning is ok, but subsequent warnings means jodconverter always starts libreoffice not keeping it alive for future requests.

  2. I start libreoffice like this manually in terminal (used 8100 port):
    libreoffice --headless --accept="socket,host=0,port=8100,tcpNoDelay=1;urp" --nodefault --nofirststartwizard --nolockcheck --nologo --norestore --invisible &
    I check that there is soffice.bin, oosplash processes are running.
    I converted one file with jodconverter (first time). Everything is ok, no warning. Conversion was successful. But after conversion soffice.bin and oosplash processes are died.
    I converted file again (second time). It also converted file but there was a warning! And all other future conversions had warnings.

Following are debug logs when warning is produced:

11:03:36,375 [info] o.j.o.OfficeProcessManager - Submitting task 'Start' and waiting...
11:03:36,386 [info] o.j.o.OfficeProcess - Starting process with acceptString 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1;urp;StarOffice.ServiceManager' and profileDir '/tmp/.jodconverter_socket_host-127.0.0.1_port-8100_tcpNoDelay-1'
11:03:36,403 [debug] o.j.p.AbstractProcessManager - Command line matches! Returning pid: 24961
11:03:36,403 [info] o.j.o.OfficeProcess - Started process; pid = 24961
11:03:36,403 [debug] o.j.o.OfficeConnection - Connecting with connectString 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1'
11:03:36,654 [debug] o.j.o.OfficeConnection - Connecting with connectString 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1'
11:03:36,655 [warn] o.j.o.ConnectRetryable - Office process died with exit code 81; restarting it
11:03:36,691 [info] o.j.o.OfficeProcess - Starting process with acceptString 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1;urp;StarOffice.ServiceManager' and profileDir '/tmp/.jodconverter_socket_host-127.0.0.1_port-8100_tcpNoDelay-1'
11:03:36,710 [debug] o.j.p.AbstractProcessManager - Command line matches! Returning pid: 24981
11:03:36,710 [info] o.j.o.OfficeProcess - Started process; pid = 24981
11:03:36,960 [debug] o.j.o.OfficeConnection - Connecting with connectString 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1'
11:03:36,964 [info] o.j.o.OfficeConnection - Connected: 'socket,host=127.0.0.1,port=8100,tcpNoDelay=1'
11:03:36,964 [debug] o.j.o.OfficeProcessManager - Task 'Start' executed successfully
11:03:36,965 [debug] o.j.o.AbstractOfficeManagerPoolEntry - Waiting for task to complete...

This is the code to convert file (fodt to pdf):

val officeManager = LocalOfficeManager.builder().portNumbers(8100).install().build()
try {
  officeManager.start()
  JodConverter
      .convert(tmpFodtFilePath.toFile)
      .to(tmpPdfFilePath.toFile)
      .execute()
} finally {
  OfficeUtils.stopQuietly(officeManager)
}

I'm using: Kubuntu (Ubuntu) 16.04, LibreOffice 5.1.6.2 10m0(Build:2), java 8, jodconverter 4.1.1 snapshot,

Macros not being run during conversion

Hello,

I'm using JodConverter (v-4.0.0) to convert some documents from docx to pdf in my web application. One of the problems that I have is that I need to update the table of contents in the input documents. To do this I created a macro in LibreOffice to update my TOC everytime a document is opened with LibreOffice. However when I use JodConverter to convert my files, the macros aren't executed and my TOC isn't updated.

Do you know if JodConverter supports this? Do I need to use some kind of config in my code for the converter to get the macros to run?
image
I saw this in an old forum and tried but it did not work.

Do you have any tips for me?

Thanks in advance!

Not able to start multiple OfficeProcesses

We run different instances of the same web application on our server, all of these instances want to start an Office process. Due to OfficeProcess.checkForExistingProcess(), only one Office process can be started, others fail to do so.

org.jodconverter.office.OfficeException: Could not establish connection
	at org.jodconverter.office.ManagedOfficeProcess.doStartProcessAndConnect(ManagedOfficeProcess.java:104) ~[org.jodconverter.jodconverter-core-4.0.0-RELEASE.jar:4.0.0-RELEASE]
	at org.jodconverter.office.ManagedOfficeProcess.access$100(ManagedOfficeProcess.java:40) ~[org.jodconverter.jodconverter-core-4.0.0-RELEASE.jar:4.0.0-RELEASE]
	at org.jodconverter.office.ManagedOfficeProcess$4.call(ManagedOfficeProcess.java:279) ~[org.jodconverter.jodconverter-core-4.0.0-RELEASE.jar:4.0.0-RELEASE]
	at org.jodconverter.office.ManagedOfficeProcess$4.call(ManagedOfficeProcess.java:275) ~[org.jodconverter.jodconverter-core-4.0.0-RELEASE.jar:4.0.0-RELEASE]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_72]
Caused by: org.jodconverter.office.OfficeException: A process with acceptString 'socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ServiceManager' is already running; pid 30201
	at org.jodconverter.office.OfficeProcess.checkForExistingProcess(OfficeProcess.java:116) ~[org.jodconverter.jodconverter-core-4.0.0-RELEASE.jar:4.0.0-RELEASE]
	at org.jodconverter.office.OfficeProcess.start(OfficeProcess.java:326) ~[org.jodconverter.jodconverter-core-4.0.0-RELEASE.jar:4.0.0-RELEASE]
	at org.jodconverter.office.OfficeProcess.start(OfficeProcess.java:305) ~[org.jodconverter.jodconverter-core-4.0.0-RELEASE.jar:4.0.0-RELEASE]
	at org.jodconverter.office.ManagedOfficeProcess.doStartProcessAndConnect(ManagedOfficeProcess.java:99) ~[org.jodconverter.jodconverter-core-4.0.0-RELEASE.jar:4.0.0-RELEASE]
	at org.jodconverter.office.ManagedOfficeProcess.access$100(ManagedOfficeProcess.java:40) ~[org.jodconverter.jodconverter-core-4.0.0-RELEASE.jar:4.0.0-RELEASE]

Any idea or workaround for this issue?

custome html format

Can i control the jodconverter convert some file to .html that the format is what i want.
Such as charset=gb2312 i need utf-8.
Sorry foy my bad English

how to prevent org.jodconverter.sample.web.WebappContextListener being a listener

I create my own listener as

public class JodConverterContextListener implements ServletContextListener {

    @Override
    public void contextInitialized(final ServletContextEvent event) {

        try {
            JodConverterContext.init(event.getServletContext());
        } catch (OfficeException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void contextDestroyed(final ServletContextEvent event) {
        try {
            JodConverterContext.destroy(event.getServletContext());
        } catch (OfficeException e) {
            throw new RuntimeException(e);
        }
    }
}
package com.gpower.services.content;

import org.jodconverter.OfficeDocumentConverter;
import org.jodconverter.office.DefaultOfficeManagerBuilder;
import org.jodconverter.office.OfficeException;
import org.jodconverter.office.OfficeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletContext;
import java.io.File;

public class JodConverterContext {

    public static final String PARAMETER_OFFICE_PORT = "office.port";
    public static final String PARAMETER_OFFICE_HOME = "office.home";
    public static final String PARAMETER_OFFICE_PROFILE = "office.profile";
    //public static final String PARAMETER_FILEUPLOAD_FILE_SIZE_MAX = "cms.openOffice.fileSizeMax";
    //  public static final String PARAMETER_CHARSET = "cms.openOffice.charset";

    private static final Logger logger = LoggerFactory.getLogger(JodConverterContext.class);
    private static final String KEY = JodConverterContext.class.getName();

    private final OfficeManager officeManager;
    private final OfficeDocumentConverter documentConverter;

    /**
     * Creates a new WebappContext using the specified servlet context.
     *
     * @param servletContext the servlet context that contains properties used to create a JOD
     *                       document converter.
     */
    public JodConverterContext(final ServletContext servletContext) {
       /* final DiskFileItemFactory fileItemFactory = new DiskFileItemFactory();
        final String fileSizeMax = SystemGlobals.getProperty(PARAMETER_FILEUPLOAD_FILE_SIZE_MAX);
        fileUpload = new ServletFileUpload (fileItemFactory);
        if (fileSizeMax == null) {
            logger.warn("max file upload size not set");
        } else {
            fileUpload.setFileSizeMax(Integer.parseInt(fileSizeMax));
            logger.info("max file upload size set to {}", fileSizeMax);
        }*/

        final DefaultOfficeManagerBuilder configuration = new DefaultOfficeManagerBuilder();
        final String officePortParam = servletContext.getInitParameter(PARAMETER_OFFICE_PORT);
        if (officePortParam != null) {
            configuration.setPortNumber(Integer.parseInt(officePortParam));
        }
        final String officeHomeParam = servletContext.getInitParameter(PARAMETER_OFFICE_HOME);
        if (officeHomeParam != null) {
            configuration.setOfficeHome(new File(officeHomeParam));
        }
        final String officeProfileParam = servletContext.getInitParameter(PARAMETER_OFFICE_PROFILE);
        if (officeProfileParam != null) {
            configuration.setTemplateProfileDir(new File(officeProfileParam));
        }

        officeManager = configuration.build();
        documentConverter = new OfficeDocumentConverter(officeManager);
    }

    protected static void init(final ServletContext servletContext) throws OfficeException {
        final JodConverterContext instance = new JodConverterContext(servletContext);
        servletContext.setAttribute(KEY, instance);
        instance.officeManager.start();
    }

    protected static void destroy(final ServletContext servletContext) throws OfficeException {
        final JodConverterContext instance = get(servletContext);
        instance.officeManager.stop();
    }

    /**
     * Gets the WebappContext from the specified servlet context.
     *
     * @param servletContext the servlet context that contains the WebappContext.
     * @return the WebappContext.
     */
    public static JodConverterContext get(final ServletContext servletContext) {
        return (JodConverterContext) servletContext.getAttribute(KEY);
    }

    /**
     * Gets the object used to process file uploads.
     *
     * @return a ServletFileUpload.
     */
   /* public ServletFileUpload getFileUpload() {
        return fileUpload;
    }*/

    /**
     * Gets the document converter of the context.
     *
     * @return the context's document converter.
     */
    public OfficeManager getOfficeManager() {
        return officeManager;
    }

    /**
     * Gets the document converter of the context.
     *
     * @return the context's document converter.
     */
    public OfficeDocumentConverter getDocumentConverter() {
        return documentConverter;
    }
}

in web.xml

 <context-param>
  <param-name>office.port</param-name>
  <param-value>8100</param-value>
 </context-param>
 <context-param>
  <param-name>office.home</param-name>
  <param-value>D:\openOffice</param-value>
 </context-param>
 <context-param>
  <param-name>office.profile</param-name>
  <!--linux 参考 /home/converter/.openoffice.org/3-->
  <param-value>C:\Users\HiJack\AppData\Roaming\OpenOffice\4</param-value>
 </context-param>
<listener>
  <listener-class>com.gpower.services.content.JodConverterContextListener</listener-class>
 </listener>

There is no org.jodconverter.sample.web.WebappContextListener in my project.
however , whenever I boot my web application in tomcat , there would be a excetion

org.apache.catalina.core.StandardContext listenerStart
 Exception sending context initialized event to listener instance of class org.jodconverter.sample.web.WebappContextListener
java.lang.IllegalStateException: officeHome not set and could not be auto-detected
	at org.jodconverter.office.OfficeUtils.validateOfficeHome(OfficeUtils.java:263)
	at org.jodconverter.office.DefaultOfficeManagerBuilder.build(DefaultOfficeManagerBuilder.java:78)
	at org.jodconverter.sample.web.WebappContext.<init>(WebappContext.java:81)
	at org.jodconverter.sample.web.WebappContext.init(WebappContext.java:86)
	at org.jodconverter.sample.web.WebappContextListener.contextInitialized(WebappContextListener.java:33)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

Debugging shows that the method build() in org.jodconverter.office.DefaultOfficeManagerBuilder called twice when tomcat booting.

Unable to compile code

Tried to build and got the following error. Was unable to resolve one of the dependencies.

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project 'jodconverter'.

Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.netflix.nebula:nebula-project-plugin:3.3.0.
Required by:
project :
> Could not resolve com.netflix.nebula:nebula-project-plugin:3.3.0.
> Could not get resource 'https://repo1.maven.org/maven2/com/netflix/ne
bula/nebula-project-plugin/3.3.0/nebula-project-plugin-3.3.0.pom'.
> Could not GET 'https://repo1.maven.org/maven2/com/netflix/nebula/n
ebula-project-plugin/3.3.0/nebula-project-plugin-3.3.0.pom'.
> Connection reset
> Could not resolve com.netflix.nebula:nebula-project-plugin:3.3.0.
> Could not get resource 'https://plugins.gradle.org/m2/com/netflix/neb
ula/nebula-project-plugin/3.3.0/nebula-project-plugin-3.3.0.pom'.
> Could not GET 'https://plugins.gradle.org/m2/com/netflix/nebula/ne
bula-project-plugin/3.3.0/nebula-project-plugin-3.3.0.pom'.
> Connection reset
Could not resolve com.diffplug.spotless:spotless-plugin-gradle:3.1.0.
Required by:
project :
> Could not resolve com.diffplug.spotless:spotless-plugin-gradle:3.1.0.
> Could not get resource 'https://repo1.maven.org/maven2/com/diffplug/s
potless/spotless-plugin-gradle/3.1.0/spotless-plugin-gradle-3.1.0.pom'.
> Could not GET 'https://repo1.maven.org/maven2/com/diffplug/spotles
s/spotless-plugin-gradle/3.1.0/spotless-plugin-gradle-3.1.0.pom'.
> Connection reset
> Could not resolve com.diffplug.spotless:spotless-plugin-gradle:3.1.0.
> Could not get resource 'https://plugins.gradle.org/m2/com/diffplug/sp
otless/spotless-plugin-gradle/3.1.0/spotless-plugin-gradle-3.1.0.pom'.
> Could not GET 'https://plugins.gradle.org/m2/com/diffplug/spotless
/spotless-plugin-gradle/3.1.0/spotless-plugin-gradle-3.1.0.pom'.
> Connection reset
Could not resolve io.spring.gradle:dependency-management-plugin:1.0.1.RELEA
SE.
Required by:
project :
> Could not resolve io.spring.gradle:dependency-management-plugin:1.0.1.RE
LEASE.
> Could not get resource 'https://repo1.maven.org/maven2/io/spring/grad
le/dependency-management-plugin/1.0.1.RELEASE/dependency-management-plugin-1.0.1
.RELEASE.pom'.
> Could not GET 'https://repo1.maven.org/maven2/io/spring/gradle/dep
endency-management-plugin/1.0.1.RELEASE/dependency-management-plugin-1.0.1.RELEA
SE.pom'.
> Connection reset
> Could not resolve io.spring.gradle:dependency-management-plugin:1.0.1.RE
LEASE.
> Could not get resource 'https://plugins.gradle.org/m2/io/spring/gradl
e/dependency-management-plugin/1.0.1.RELEASE/dependency-management-plugin-1.0.1.
RELEASE.pom'.
> Could not GET 'https://plugins.gradle.org/m2/io/spring/gradle/depe
ndency-management-plugin/1.0.1.RELEASE/dependency-management-plugin-1.0.1.RELEAS
E.pom'.
> Connection reset

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug
    option to get more log output.

BUILD FAILED

No-args constructor for DocumentFormat does not exist

Hi,

I'm attempting to upgrade from the abandoned version of JODConverter to your new improved one. Package names ("artofsolving") and API has changed slightly but appears to be very similar. I thought I hooked everything up properly but now when I try to convert an image to PDF I get the following error.

RuntimeException: No-args constructor for class org.jodconverter.document.DocumentFormat does not exist. Register an InstanceCreator with Gson for this type to fix this problem.

Any ideas?

Thanks,

Support for the latest LibreOffice

The LibreOffice 6 has been released. The default installation path is changed from "C:\Program Files\LibreOffice 5" to "C:\Program Files\LibreOffice".

Encoding support

@sbraconnier are you going to support your branch?
Do you know does OO/jodconverter support converting with setting output file's encoding?

Document export / conversion image properties

I am looking for a bit of guidance here, as I have been searching for a few days now and just can't seem to find the correct settings I am after. When using LibreOffice you can export a office document (.docx) as a .png image. When doing this operation through LibreOffice itself, you have the options to specify the final image Height/Width/DPI. I want to be able to configure the same information when using the LocalConverter. I am assuming I need to set the storeProperties map on either the converter of the target DocumentFormat, but I can't seem to find what the name/value pair for the map needs to be.

Can anyone point me in the right direction for configuring these options?

How do i convert a partucular word document(docx) page to html?

I was using jodconvertor for converting my word documents into an HTML document. However, i have a requirement to convert a particular page from docx into HTML. Can we do that? If so, is there any code sample you could show or any unit test case you could point me to.

Add merging support.

Create a new filter that will take the content of a document and append it at the end of the document being converted. This will add merging support, as required here #42

Jodconverter and office in different hosts

I have two docker container: one with libreoffice (--headless --accept='socket,host=0,port=8997,tcpNoDelay=1;urp;') and another one with java server application with jodconverter. How can I configure OfficeManager to interoperate with office in another container?
As I understand, LocalOfficeManager works only with office on localhost. I try to use OnlineOfficeManager, but conversion failed by timeout.

Add JodConverter Online to the spring boot starter

The spring boot starter should allow the user to enable (and configure) both the jodconverter-local and the jodconverter-online modules. This would probably introduce a breaking change sine the jodconverter-local properties will now be under the jodconverter.local properties (instead of jodconverter alone).

Add SSL support for JODConvetrer Online module

The module jodconverter-online 4.1.0 does not support SSL.

The module should allow an advanced SSL configuration, including SSL client authentication, support for self-signed certificate, hostname verification strategy, etc...

Changing Margins when converting .rtf to .pdf

I have to convert some documents from rtf to pdf. Basically it works.
but i've to change the margins of the new document.
I read the wiki, and thinked of using a Filter could do this, but nothing changed the new pdf..

What have i done wrong?

Here is my new Filter:

public class PageMarginFilter implements Filter {

	private final long  topMargin;
	private final long  righttMargin;
	private final long  bottomMargin;
	private final long  leftMargin;
		
	public PageMarginFilter( final long topMargin, final long rightMargin, final long bottomMargin, final long leftMargin ) {
		super();
			
		this.topMargin = topMargin;
		this.righttMargin = rightMargin;
		this.bottomMargin = bottomMargin;
		this.leftMargin = leftMargin;
			
	}
		
	@Override
	public void doFilter( OfficeContext context, XComponent document, FilterChain chain ) throws Exception {
			
		final XTextDocument docText = UnoRuntime.queryInterface( XTextDocument.class, document );
		final XMultiServiceFactory docServiceFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, docText );
		final XStyle xStyle = UnoRuntime.queryInterface( XStyle.class, docServiceFactory.createInstance( "com.sun.star.style.PageStyle" ) );
		final XPropertySet xPSetPageStyle = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xStyle );
		xPSetPageStyle.setPropertyValue ( "LeftMargin", leftMargin );
			
		chain.doFilter( context, document );
	}
		
}

and this is how i used it:

LocalConverter
		.builder()
		.officeManager( officeManager )
		.filterChain( pageMarginFilter )
		.build()
		.convert( inputStream )
		.as( DefaultDocumentFormatRegistry.RTF )
		.to( outputStream )
		.as( DefaultDocumentFormatRegistry.PDF )
		.execute();

I'm using Java 8 and JODConverter 4.1

Don't start or kill libreoffice related processes automatically.

I couldn't find necessary functionality from spec, and here is an idea:
We need config param to control creating libreoffice processes. Now if libreoffice process is not running jodconverter tries to start it automatically. I think it should not start/restart office process and should depend on some config parameter.
It can be autoStartOfficeProcess param and by default it might be true. If user sets false to this param, jodconverter shouldn't start/restart office process and should throw error about not running process. User takes responsibility for running processes.
Note: old jodconverter 2.2.1 by default didn't start office process. This feature (starting process automatically) is good and should be controlled by user.

some class can't find from the maven jar

 I get the jar from maven:
  org.jodconverter
  jodconverter-core
  4.0.0-RELEASE

But i can't find the class below:DefaultOfficeManager ,DocumentConverter  etc,whether it need to be updated?

qq 20170713110934

Service call /service as in old jodconverter

Is it possible to call the webservice remotely as was possible with the old jodconverter?

I noticed there is this mapping missing:

DocumentConverterServiceServlet /service

And obviously the code I want to run is calling this URL http://localhost/service.

For reference the feature was:

/**
 * This servlet offers a document converter service suitable for remote invocation
 * by HTTP clients written in any language.
 * <p>
 * To be valid a request to service must:
 * <ul>
 *   <li>use the POST method and send the input document data as the request body</li>
 *   <li>specify the correct <b>Content-Type</b> of the input document</li>
 *   <li>specify an <b>Accept</b> header with the mime-type of the desired output</li>
 * </ul>
 * <p>
 * As a very simple example, a request to convert a text document into PDF would
 * look something like
 * <pre>
 * POST /jooconverter/service HTTP/1.1
 * Host: x.y.z
 * Content-Type: text/plain
 * Accept: application/pdf
 * 
 * Hello world!
 * </pre>
 */

How to configure the macOS officeHome?

/Applications/OpenOffice.app/Contents?

Exception in thread "Thread-38" java.lang.IllegalStateException: officeHome not set and could not be auto-detected
at org.jodconverter.office.LocalOfficeUtils.validateOfficeHome(LocalOfficeUtils.java:317)
at org.jodconverter.office.LocalOfficeManager$Builder.build(LocalOfficeManager.java:136)
at org.jodconverter.office.LocalOfficeManager.install(LocalOfficeManager.java:67)
at com.doc.tools.Office2PdfTool.run(Office2PdfTool.java:91)
at java.lang.Thread.run(Thread.java:748)

Consider not adding "default to" in property description

spring-boot-configuration-processor extracts the default value and put in in a dedicated field in the metadata. IDEs use that information to show the default value in auto-inspection and in the detail panel.

Please consider not including "default to" in the description as this information is redundant.

Add support for Flat XML formats

Add support to convert from to fodt, fods, fodp and fodg formats (Flat XML formats), as specified in #42.

Those will work only with LibreOffice.

why it must need a extension in the source file?

if I give a source file named 'abc.doc', the converter is very good.
But, if source file named 'abc', it will go wrong.
And,the converter also can run when I remove the extension check. So ,I think you can remove the source file extension check in the code. here is a PR

Error trying to build.

Tried to build the project but got the following error:

FAILURE: Build failed with an exception.

  • Where:
    Build file 'C:\jodconverter-master\build.gradle' line: 116

  • What went wrong:
    A problem occurred evaluating root project 'jodconverter'.

Could not get unknown property 'ossrhUsername' for NexusStagingExtension(serve
rUrl:https://oss.sonatype.org/service/local/, username:null, password:null, pack
ageGroup:null, stagingProfileId:null, numberOfRetries:20, delayBetweenRetriesInM
illis:2000) of type io.codearte.gradle.nexus.NexusStagingExtension.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug
    option to get more log output.

BUILD FAILED

Total time: 1.89 secs

Use of Spring 5 with Spring Boot 1.x is unusual

Rather than having a dependency management for Spring and Spring Boot separately, could you please just align and use Spring Boot's dependency management instead? Spring Boot 2.0 GA is around the corner now with proper integration with Spring Framework 5.

Thanks

Help needed: "An office manager is required in order to build a converter"

Hi there!
I hope you can help me with this as I found no more example codes.
If this is the wrong place to ask this kind of question, then I'm sorry.

I used the code snippets from https://github.com/sbraconnier/jodconverter/wiki/Java-Library and /Configuration#file_folderofficehome to get a very simple function to convert a DOC to PDF:

OfficeManager officeManager = LocalOfficeManager.builder().officeHome(officePath).build();
try {
	officeManager.start();
	long start = System.currentTimeMillis();
	JodConverter.convert(new File(src)).to(new File(dest)).execute();
	Logger.writeToLog("Generated pdf in " + (System.currentTimeMillis() - start) + " ms");
} catch (Exception ex) {
	Logger.writeToLog(ex);
} finally {
	OfficeUtils.stopQuietly(officeManager);
}

There's a very high change I got something wrong here, but I have absolutely no clue as Eclipse compiles with no errors.

I'm using the CORE and the LOCAL jars (both downloaded from MvmRepo) and resolved all the dependencies.

The code above is the complete function to get called with 3 params: source file, destination file and officePath. I can't use LocalOfficeManager.install() because I don't have a default install of LibreOffice.

I'm on MacOS and use /Volumes/Applications/LibreOffice.app/Contents as officePath variable here.

Any help or hint is appreciated!

Thank You!

Best
Daniel

Merge multiple fodt files and convert to PDF

I'm using old version of jodconverter 2.2.1. I don't know if it's possible to merge multiple fodt files and then convert to pdf file. Now I can convert 1 fodt file to pdf.
I find this fork, I want to use it if it supports converting multiple files to 1 pdf file (merge then convert).
For example: I've a.fodt, b.fodt, c.fodt, extra.fodt files. I want this a.fodt + extra.fodt => result.pdf, b.fodt + extra.fodt => result2.pdf, ...

Updating from 4.0.0-RELEASE to 4.1.0 where are this classes?

Unable to find this classes:

org.jodconverter.OfficeDocumentConverter;
org.jodconverter.office.DefaultOfficeManagerBuilder;

They are no longer there so I assume the approach was changed. I was unable to find documentation about it. You probably need to consider Wiki pages to upgrade from one version to another when things like this happen.

Advice on how to implement a custom local office task

Hello,

I want to implement my own custom local office task to be processed on libreoffice using the JODConverter classes. I intend to base my work on yours since the JODConverter has a beautiful implementation of different types of connections as well as process handling etc. Can you give me a recommendation on how to achieve the following:

CreatingADocumentUsingLOTask cadulot = new CreatingADocumentUsingLOTask(...some params for the task...);
LocalOfficeManager manager = LocalOfficeManager.install();
manager.execute(cadulot);
manager.stop();

Which parts do I have to implement my custom CreatingADocumentUsingLOTask to allow it to be executed? What I want to do in there is to load a libreoffice template, edit some parts, replace some placeholders and finally export the document to a stream. I can do that already using my own classes, however, I now want to transform it into a task I can execute using JODConverter. How can I do this?

Thanks!

Is there going to be a new release soon?

Hello,

I see that you revived JODConverter from the dead and built a pretty descent library out of it. Thanks for your work! Now since the last release, you did a larger refactoring into local and remote part. Is there going to be a new release soon?

Import documentation from former JODConverter site.

The original author of JODConverter generously and positively answered to my request, which was about the content of the now unresponsive former JODConverter web site. My goal is to import (and update) the documentation here on GitHub.

Issue with soffice.bin and findPid in MacOS

  1. In the class OfficeUtils, EXECUTABLE_MAC_41 is should be MacOS/soffice instead of MacOS/soffice.bin

  2. In the class OfficeProcess at line 343: pid = processManager.findPid(processQuery) in MacOS:
    the pid is always returned PID_NOT_FOUND that caused the program exit, I think there is error in the method findPid that is different with Ubuntu.

I changed MacOS/soffice.bin to MacOS/soffice and comment out the check of if(pid == PID_NOT_FOUND), then the program can convert doc to html.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.