Hi everyone,

i'm having a problem and hopefully you can help me. Until now i always used MergeFields to import information from ivy to a word-document by using e.g. the following instructions:

import ch.ivyteam.ivy.addons.docfactory.TemplateMergeField;

in.MergeField.add(new TemplateMergeField("FIELD1", in.xxx));

At the moment im facing the problem that i can't import .png files. It doesn't work when the data is from the type "string" because only the Path will be importet but also when the data-type is from the type "file". From my point of view it is because the mergefields only support the type "string" - is it possible to change it to the type "file" (?)

If not - is there a work around?

Thank you very much for your time

asked 17.06.2016 at 13:39

Spfl_'s gravatar image

Spfl_
16336
accept rate: 0%


Hi,

I have tested it in IvyScript with the Ivy File type. Please get the Files path with getAbsolutePath()

import ch.ivyteam.ivy.addons.docfactory.TemplateMergeField;
import ch.ivyteam.ivy.addons.docfactory.FileOperationMessage;
import ch.ivyteam.ivy.addons.docfactory.DocumentTemplate;

File image = new File("logo-euro.jpg"); File template = new File("template_picture.docx"); // mergefield named Image:FIELD1

List<templatemergefield> mergeFields = new List(); mergeFields.add(new TemplateMergeField("FIELD1", image.getAbsolutePath()));

DocumentTemplate dt = new DocumentTemplate(template.getAbsolutePath(), ivy.wf.getApplication().getFileArea().getAbsolutePath(), "result", "pdf", mergeFields);

FileOperationMessage fom = dt.generateDocument(); ivy.log.info("Result success ? {0} and document produced in {1}", fom.isSuccess(), fom.files.get(0));

I get Result success ? true and document produced in D:\ivy\designer\6.1\files\application\result.pdf

It works fine : alt text

Cheers Emmanuel

link

answered 20.06.2016 at 15:46

Emmanuel's gravatar image

Emmanuel
175131619
accept rate: 66%

edited 20.06.2016 at 15:49

I have tested it also with a png file (instead of a jpg). The result is the same. It works.

(20.06.2016 at 15:54) Emmanuel Emmanuel's gravatar image

Works fine! Thank you very much.

(21.06.2016 at 09:45) Spfl_ Spfl_'s gravatar image

Hi,

So it is quite easy (I guess) :) First in your template, your image mergefield name should start with "Image:" This allows the DocFactory Backend to intercept the mail merge operation and see it has to insert an image there. For Example: "Image:my_logo" You do then:

in.MergeField.add(new TemplateMergeField("my_logo", in.myLogoFile.getAbsolutePath()));

This should work.

A new improved version of the IvyAddOns in on the way with the possibility of using java.io.File objects directly as parameters.

I hope this will help you

Regards Emmanuel

link

answered 17.06.2016 at 14:05

Emmanuel's gravatar image

Emmanuel
175131619
accept rate: 66%

edited 20.06.2016 at 15:46

Thanks so far. But it's still not working.

The MergeField in the template is called «Image:FIELD1» The myLogoFile type is a java.io.File The Expression of the myLogoFile is "(new File("xxx.png")).getJavaFile()" The png. file is stored in [...]\AxonIvyDesigner6.1.0.51350_Windows_x64\files\application

The pdf shows still the whole link.

May you find the mistake? Thank you!

(20.06.2016 at 10:17) Spfl_ Spfl_'s gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×75

Asked: 17.06.2016 at 13:39

Seen: 919 times

Last updated: 21.06.2016 at 13:17