New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge multiple fodt files and convert to PDF #42
Comments
I'm using java 8, playframework, scala, sbt. |
Out of the box it is not possible, but the missing parts could be added with little effort. I find the idea quite interesting so I will check how to do this (within a week) and come back to you with my results. The missing parts are that fodt is not supported by default (but can be added easily, I'll open an issue to support it by default) and the other part would be to create a Filter that would merge a document to the original document being converted. Such a filter could then be added to the filter chain for each document to merge. |
Could you please try the latest version of the master branch? You will have to use the new DocumentInserterFilter in order to merge documents. Using the same example you provided: final DocumentInserterFilter inserterFilter = new DocumentInserterFilter(new File("extra.fodt"));
// Merge a.fodt with extra.fodt to produce result.pdf
LocalConverter
.builder()
.filterChain(inserterFilter)
.build()
.convert(new File("a.fodt"))
.to(new File("result.pdf"))
.execute();
// Merge b.fodt with extra.fodt to produce result2.pdf
LocalConverter
.builder()
.filterChain(inserterFilter)
.build()
.convert(new File("b.fodt"))
.to(new File("result2.pdf"))
.execute(); Note that you can merge multiple documents. The following example would merge a.fodt, b.fodt, c.fodt and extra.fodt to produce result.pdf: final DocumentInserterFilter bFilter = new DocumentInserterFilter(new File("b.fodt"));
final DocumentInserterFilter cFilter = new DocumentInserterFilter(new File("c.fodt"));
final DocumentInserterFilter extraFilter = new DocumentInserterFilter(new File("extra.fodt"));
// Merge a.fodt with extra.fodt to produce result.pdf
LocalConverter
.builder()
.filterChain(bFilter , cFilter, extraFilter)
.build()
.convert(new File("a.fodt"))
.to(new File("result.pdf"))
.execute(); |
Thank you for positive response and effort! I'll try to use it soon. |
Tried to concatenate 2 fodt files and generate pdf file:
But |
Which version of LibreOffice is it ? Is it possible for you to provide me with files (removing all sensitive data) I could use to reproduce your problem. On my end, everything works just fine. Can you try the 4.1.1-SNAPSHOT version available in the OSS snapshots repository: |
libreoffice version is
Attaching 3 files. Input (test1.fodt, test2.fodt) and output (test_result.pdf). Archived fodt files because github didn't allow to attach them. |
That one is not easy... It seems to be related to "fodt" format. If you convert the fodt to odt first, it works: val officeManager = LocalOfficeManager.builder().install().build()
officeManager.start()
val fodt1 = Paths.get("/home/user/tmp/files/test1.fodt").toFile
val odt1 = Paths.get("/home/user/tmp/files/test1.odt").toFile
val fodt2 = Paths.get("/home/user/tmp/files/test2.fodt").toFile
val odt2 = Paths.get("/home/user/tmp/files/test2.odt").toFile
val pdfMerged = Paths.get("/home/user/tmp/files/test_result.pdf").toFile
LocalConverter.make().convert(fodt1).to(odt1).execute()
LocalConverter.make().convert(fodt2).to(odt2).execute()
val inserterFilter = new DocumentInserterFilter(odt1)
LocalConverter
.builder()
.filterChain(inserterFilter)
.build()
.convert(odt2)
.to(pdfMerged)
.execute() I'll try to find out why, but I'm not that confident that I'll find a better option... |
Thanks! That is useful too. |
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, ...
The text was updated successfully, but these errors were encountered: