Displaying text in SVG using Java - java

I am successfully drawing a line in an svg using java. The line tag or name is shown using a GWT label in a div containing the svg. Is there a way to display tag using svg itself? (without using label and div's)

OMSVGTextElement element;
private OMSVGSVGElement svgElement;
svgElement = doc.createSVGSVGElement();
element=doc.createSVGTextElement();
element.getElement().setInnerText("link label"); //the label
svgElement.appendChild(element);
This should do.

Related

How to remove hyperlink style using PDFBox

I was able to disable hyperlink using
PDActionHide actionshow = new PDActionHide();
actionshow.setH(true);
However I want to remove blue colour hyperlink but keep the text. How do I do this using Apache PDFBox?
Do this (works only if the line is part of the annotation and not of the content stream):
PDAnnotationLink txtLink = ...
txtLink.setBorderStyle(null);
txtLink.setBorder(new COSArray());
this removes the border style and sets an empty color.

JLabel with HTML inline image

I'm trying to create a JLabel with mixed content: text and inline images.
The component later should contain dynamically count of images and text (with dynamically order).
My first steps: Create an JLabel like follows:
JLabel label = new JLabel("<html>wow! <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAMAAABiM0N1AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAFQUExURUxpcbdSB+dzD+yFFQsEAPSHFhwMABkMAAAAAMpkC9l2EspgCoRHCUMiA+mEFPOOFcBpD/CDFPB9FOh+E08nA+99E+h2E9prDrRgDa5fDrVhC7FiD//JOv/LOf/adv/PKv/IKvuqIf/LPf/OMP/qufuxJP/aLP/GNf7CKPqkIP/UK//tw//glvy1J//bgP/fjv/ehvueHf+/M//jnP/ko//mqf28JvmSGP/or//RVf/Xa//uzPr6++fn6JRfEP/TXcN/Ftzb2v25LqhtEvuZG//WZFkgAKBmEX1OColVDMmJGf/gLbt6Ff/OScjJyciEF7JxE3Q8B/7yNGcqAv3pMf/x1quAG/7TQWQ9BUsyBIx4ZL6cJ7GLIcuqJNi0I/3hTOzcLlQ1BHRKHcSKGbSuqP/FTv7PdPjMaebMT6KWiVZBH3pdQdKzT93PK/m/Qfrx4U/NK0MAAAAcdFJOUwAWeucu/iIFEkmxK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xhBGEHw9uuQ/7r+BdVmcTguphkzAAAAAElFTkSuQmCC"></html>");
If I add the label to a component, it looks like this:
-> missing image!
But if I put the html code from the label inside an .html file and open it with chrome, it looks good:
What am I doing wrong?
Regards,
Florian
Try to add your image with the setIcon() method of Jlabel :
ImageIcon icon = new ImageIcon(YOUR_PATH);
JLabel thumb = new JLabel();
thumb.setIcon(icon);
By replacing YOUR_PATH by the absolute oath of your image.
Hope it will help !
EDIT : (If you really want to use html image tag, Java may encounter some difficulties in finding your image : use this to have a correct path usable by your program (supposing your image is in the current directory) :
URL url = HTMLLabel.class.getResource( "/image.png" );
Then access your image like this :
"...<img src =" + url + "/> ..."

Display HTML text in SWT Label

I would like to display the HTML text in a Java SWT Label.
Below is my code for creating a label.
Label theLabel = new Label(controls,SWT.WRAP);
theLabel.setSize(100,500);
theLable.setText("<html><ol><li>Hello</li><li>welcome</li></ol></html>");
When I run the application as Eclipse Application I get the output as:
<html><ol><li>Hello</li><li>welcome</li></ol></html>
What is the mistake? Why I am not getting the html formatted output in my label? I am using Eclipse plugin with a view.
To show HTML with SWT you will have to use the Browser widget instead.
Browser browser = new Browser( parent, SWT.NONE );
browser.setText( "<html><ol><li>Hello</li><li>welcome</li></ol></html>" );
If you don't mind the extra dependency on org.eclipse.ui.forms you can also use FormText. But be aware that the control does only understand a subset of HTML (<p>, <b>, <li>, <img>, <br>, <span>) to render simple formatted text.

JasperReports: add List of images to PDF document

I am generating PDF documents. It is OK. All works.
I have only one problem: on each PDF page I need about 10 images (QR codes). Is it possible to
put List of java.awt.Image to JasperReport template? Put each image in separate field is complicated...
Example:
In template I have image components with these settings (http://goo.gl/wcESGp):
Expression Class: java.awt.Image
Image Expression :
com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(
new com.google.zxing.qrcode.QRCodeWriter().encode(
$F{CONTENT_TO_ENCODE},
com.google.zxing.BarcodeFormat.QR_CODE, 300, 300))
One image is no problem - just set field in template and put image to field in Java code. How can I fill images in JasperReports report template with List<Image>?

java gwt draw horizontal line

How can I draw a horizontal line in java gwt, something similar to the '< hr >' tag in HTML? I tried it by using
com.google.gwt.user.client.Element bottomLine = DOM.createDiv();
but that somehow doesn't work in IE...
You can use the HTML widget to add whatever html you want inside your page
HTML html = new HTML("<hr style=\"width:100%;\" />")
rootPanel.add(html); // or add it inside another widget
Or you can use css on Panel and define the border-bottom property (if you have a panel that spans the entire page).
Document.get().createHRElement()?

Categories

Resources