Comments (9)
I'm using java 8, playframework, scala, sbt.
from jodconverter.
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.
from jodconverter.
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();
from jodconverter.
Thank you for positive response and effort! I'll try to use it soon.
from jodconverter.
Tried to concatenate 2 fodt files and generate pdf file:
val fodt1 = Paths.get("/path/to/file1.fodt").toFile
val fodt2 = Paths.get("/path/to/file2.fodt").toFile
val pdfMerged = Paths.get("/path/to/merged_3.pdf").toFile
val inserterFilter = new DocumentInserterFilter(fodt1)
LocalConverter
.builder()
.filterChain(inserterFilter)
.build()
.convert(fodt2)
.to(pdfMerged)
.execute()
But merged_3.pdf
file contains only file1.fodt
file content. It's ignoring fodt2.
from jodconverter.
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:
https://oss.sonatype.org/content/repositories/snapshots/
from jodconverter.
libreoffice version is LibreOffice 5.1.6.2 10m0(Build:2)
This is the code:
val officeManager = LocalOfficeManager.builder().install().build()
officeManager.start()
val fodt1 = Paths.get("/home/user/tmp/files/test1.fodt").toFile
val fodt2 = Paths.get("/home/user/tmp/files/test2.fodt").toFile
val pdfMerged = Paths.get("/home/user/tmp/files/test_result.pdf").toFile
val inserterFilter = new DocumentInserterFilter(fodt1)
LocalConverter
.builder()
.filterChain(inserterFilter)
.build()
.convert(fodt2)
.to(pdfMerged)
.execute()
Attaching 3 files. Input (test1.fodt, test2.fodt) and output (test_result.pdf). Archived fodt files because github didn't allow to attach them.
test_result.pdf
test_fodt_files.tar.gz
from jodconverter.
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...
from jodconverter.
Thanks! That is useful too.
from jodconverter.
Related Issues (20)
- pptx file conversion of PDF failed HOT 1
- Why Task was cancelled automatically HOT 2
- StoreProperties property settings HOT 1
- Temp folder not deleted after Timeout Exceptions HOT 5
- High memory consumptiom while converting even 2-3MB of excel files to PDF HOT 5
- The Word document with more than 12 pages will automatically cancel the task. HOT 4
- Started process; pid = -2
- Error when converting Excel to PDF HOT 3
- The program running on Docker keeps generating zombie processes.
- Not working with quartz? HOT 13
- I have a question about conversion options (password, page size ,etc) HOT 10
- Xslx SparkLine HOT 1
- Decimal number, from comma to dot HOT 17
- Information about supported properties and their meaning HOT 2
- LocalOfficeManager not killing existing process on the same port HOT 4
- Same issue with Temporary file name added in CSV -> PDF conversion HOT 3
- jodconverter-local 4.4.3 or later causes the service to fail to end. HOT 7
- org.jodconverter.core.office.OfficeException: Task was cancelled: LocalConversionTask HOT 6
- Please remove unnecessary `@ConfigurationPropertiesScan` on `JodConverterLocalProperties` and `JodConverterRemoteProperties` HOT 3
- Coversion of HTMLs(generated out of emls) to PDF is taking almost 9 minutes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jodconverter.