Hi Adrian,
I ran into the same issue and found that this only works with image mode set to base64 in the ckeditor widget. If its too late to make that change then you can use a java action to parse your html string and replace all of the image tags src with the base64 string.
Here is an example using the jsoup library. This has a string input and string output. I think the only thing you would need to change is the module name and entity name in the xpath retrieve. Also I used the image upload microflow setting in the ckeditor to call a microflow when an image is uploaded. I used the base64 community commons java action to convert the image to base64 and store the string in the entity. You could also edit the java action to convert the image to base64 instead of storing the string in an attribute.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
// Special characters, e.g., é, ö, à, etc. are supported in comments.
package docugen.actions;
import java.util.List;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;
import org.jsoup.Jsoup;
import org.jsoup.select.Elements;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Document;
import com.mendix.systemwideinterfaces.core.IMendixObject;
import docugen.proxies.TemplateImage;
import com.mendix.core.Core;
public class ReplaceImages extends CustomJavaAction<java.lang.String>
{
private java.lang.String HTML;
public ReplaceImages(IContext context, java.lang.String HTML)
{
super(context);
this.HTML = HTML;
}
@java.lang.Override
public java.lang.String executeAction() throws Exception
{
// BEGIN USER CODE
//create variables to use later
String src;
String base64String;
String base64Prefix = "data:image/png;base64,";
String base64Complete;
//parse document
Document doc = Jsoup.parse(HTML);
//retrieve all img tags
Elements img = doc.getElementsByTag("img");
//loop through image tags
for (Element el : img) {
// If alt is empty or null or already has the base64 encoded
if(el.attr("src") == null || el.attr("src").contains(base64Prefix) || el.attr("src").equals("")) {
//dont change anything if it is already base64 encoded
} else if (el.attr("src").contains("file?guid=")){
//the id is stored with a prefix of file?guid= , so we split the string in two from the equal sign, and then store the object id in a variable
src = el.attr("src");
String[] parts = src.split("=");
String id = parts[1];
//retrieve mendix object list by id
List<IMendixObject> result = Core.retrieveXPathQuery(context(), "//DocuGen.TemplateImage[id" + "='" + id + "']");
//the list will always contain one object, so take the first object out of the result list
IMendixObject firstObj = result.get(0);
//Retrieve the base64 string and add the base64 prefix
base64String = firstObj.getValue(context(), TemplateImage.MemberNames.Base64String.toString());
base64Complete = base64Prefix + base64String;
//change the img tag to contain the base64 string
el.attr("src", base64Complete.toString());
} else {
//dont change anything
}
}
return doc.toString();
// END USER CODE
}
/**
* Returns a string representation of this action
*/
@java.lang.Override
public java.lang.String toString()
{
return "ReplaceImages";
}
// BEGIN EXTRA CODE
// END EXTRA CODE
}
Hope this helps!
there is the print screen to pdf on app store, but the library is not updated.
I have modified this, you can down load via git hub
https://github.com/qntbkk/printscreentopdfth
to build : gulp build
will generate the .mpk file at folder test
copy this to your project widget folder,
usage: just specific a class name to print inside the widget
Hope this help