Shrimp007 / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

Add possibility to insert the content of a Docx in an other Docx #391

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For one of my project, I need to found a way to insert the content of a Docx 
document (wish may be complex) into my template document.

For example in one page:

1. Paragraph 1
$other_file_content

2. Paragraph 2
....
3. Paragraph 3
....

I can not simply merge the two converted PDF because the result need to be in 
only one page

We can, for example, use this feature like:

InputStream in = new FileInputStream("D:\\test.docx");
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in, "MyId", 
TemplateEngineKind.Velocity);

FieldsMetadata metadata = report.createFieldsMetadata();
metadata.addFieldAsTextStyling("other_file_content", SyntaxKind.Document);

IContext context = report.createContext();
context.put("other_file_content", new File("D:\\test_inc.docx"));

report.process(context, new File("D:\\test_Out.docx"));

And it will automatically merge style, insert image form the included file into 
the result document

Original issue reported on code.google.com by gueri...@free.fr on 17 Apr 2014 at 11:51

GoogleCodeExporter commented 9 years ago
XDocReport doesn't provide the capability to merge 2 docx (it's a big hard 
task). And goal of XDocReport is to design a report with simply mean (not to 
have several piece of docx to merge).

To manage your case, you have several choices : 

1) if your 2 docx to merge are the same (ex : you generate a docx for person1, 
and other docx for person2), you can have one docx and set a #foreach on the 
top of your docx which loops for list of your model (ex : list of persons).

2) OR generate your 2 docx with XDocReport, and merge it with docx4j (please 
post your question on docx4j)

3) OR generate your 2 docx, convert it to PDF and use PDF merge tools (PdfBox, 
iText?)

Regards Angelo

Original comment by angelo.z...@gmail.com on 17 Apr 2014 at 12:40

GoogleCodeExporter commented 9 years ago
cleanup

Original comment by pascal.leclercq on 10 Oct 2014 at 7:37