Closed tnakamot closed 7 years ago
The "Invalid nested tag" issue was solved by merging the pull request, so it should be possible to use img tags with external images via http. I'll do some testing with local images and how we can manage those.
Images mostly work in the current version, however I noticed at least once place where including a rather large image can cause an entire following section to disappear when converted to PDF.
In the IRIS model files, in the file imager/detector-assembly/publish-model.conf, the image
causes layout problems in the PDF, maybe due to the size of the image. The problem only showed up in the "is" component that subscribes to the item and displays the text, including the image. The send and received commands section gets lost in the PDF output.
It turns out that the size of the image is not the problem. Including any image in the model files causes problems with the PDF output, however I found a workaround for the problem.
Instead of using the markdown syntax:
![label](image.png)
use the HTML syntax for images:
<img width="100%" height="100%" src="image1.png"/>
The HTML generated from the markdown doesn't include the width and height attributes. For a test, I changed the images in the IRIS model files to use the HTML syntax and that solved the display problems I was seeing.
Thank you for finding out that workaround.
This is a feature request to add image support to ICD database. It is important to include images (sequence diagrams, state machine diagrams, diagram which defines coordinates, etc.) to define ICD. It is quite common to have some kind of images in ICD, and I think it is essential for ICD database to support images so that it can replace Word version of ICD completely.
With the current version of ICD database, it is possible to insert the images using markdown format !()[] and that markdown is finally converted to tag, but this approach has several problems. First of all, the images have to be accessible via public HTTP server or equivalent, which is not sometimes easy to prepare, and those images have to be managed separately from model files. The revision of the images should be controlled in the same scheme as the model files, namely git, because they are tightly coupled. So, it would be nice if ICD database tools will be able to import image files in the same directory as model files into MongoDB and show them in ICD Web Server, or embed those images into PDF.
The current version of "icd" command has a relevant bug that it cannot generate PDF if a model file has !()[] markdown in it. Here is the command that I executed and the corresponding error message.
$ icd --validate imager/adc-assembly -o output.pdf com.itextpdf.tool.xml.exceptions.RuntimeWorkerException: Invalid nested tag a found, expected closing tag img. at com.itextpdf.tool.xml.XMLWorker.endElement(XMLWorker.java:135) at com.itextpdf.tool.xml.parser.XMLParser.endElement(XMLParser.java:397) at com.itextpdf.tool.xml.parser.state.ClosingTagState.process(ClosingTagState.java:71) at com.itextpdf.tool.xml.parser.XMLParser.parseWithReader(XMLParser.java:237) at com.itextpdf.tool.xml.parser.XMLParser.parse(XMLParser.java:215) at com.itextpdf.tool.xml.parser.XMLParser.parse(XMLParser.java:176) at com.itextpdf.tool.xml.XMLWorkerHelper.parseXHtml(XMLWorkerHelper.java:226) at com.itextpdf.tool.xml.XMLWorkerHelper.parseXHtml(XMLWorkerHelper.java:184) at csw.services.icd.IcdToPdf$.saveAsPdf(IcdToPdf.scala:68) at csw.services.icd.IcdToPdf$.saveAsPdf(IcdToPdf.scala:54) at csw.services.icd.IcdPrinter$.saveAsPdf$1(IcdPrinter.scala:47) at csw.services.icd.IcdPrinter$.saveToFile(IcdPrinter.scala:37) at csw.services.icd.IcdPrinter$.saveToFile(IcdPrinter.scala:24) at csw.services.icd.Icd$$anonfun$run$4.apply(Icd.scala:70) at csw.services.icd.Icd$$anonfun$run$4.apply(Icd.scala:69) at scala.Option$WithFilter.foreach(Option.scala:209) at csw.services.icd.Icd$.run(Icd.scala:69) at csw.services.icd.Icd$.delayedEndpoint$csw$services$icd$Icd$1(Icd.scala:51) at csw.services.icd.Icd$delayedInit$body.apply(Icd.scala:10) at scala.Function0$class.apply$mcV$sp(Function0.scala:34) at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) at scala.App$$anonfun$main$1.apply(App.scala:76) at scala.App$$anonfun$main$1.apply(App.scala:76) at scala.collection.immutable.List.foreach(List.scala:381) at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35) at scala.App$class.main(App.scala:76) at csw.services.icd.Icd$.main(Icd.scala:10) at csw.services.icd.Icd.main(Icd.scala)