-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text in svg not work #164
Comments
@vipcxj could you be so kind and paste the full stack trace? Thank you. |
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 |
You mean, you tried to render this code: <html>
<body>
<svg version="1.1"
baseProfile="full"
width="300" height="200"
xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="red" />
<circle cx="150" cy="100" r="80" fill="green" />
<text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text>
</svg>
</body>
</html> and you always get this exception? I can not reproduce that problem on JDK 1.7, JDK 1.8 and JDK 9 on Mac OS 10.13.2. Works for me, sorry :( What OS and JDK are you using? The exception is in the JDK font library while trying to paint a character from a composite font. Did you change the text to contain non US-Ascii letters? If you are running on Linux: Are your fonts correctly set up? You are using X11, right? Something seems strange on your setup, because this simple sample should not cause a exception in the JDK font library. |
I am on my vacation. I will try to make a unit test to clear the problem in Tuesday. |
I am wrong. I write a unit test. And everything work properly. My develop environment is windows with sun jdk. However, my product environment is linux with open jdk. So I think open jdk may cause the problem. I will do more test. |
test-project |
I cloned your project and added this lines to the Boot-class public static void main(String[] argv){
new Boot().init();
} as I never used WildFly and also have not really an idea about how exactly I would build a docker image out of this... (I don't use docker myself). Works fine for me with Oracle JDK 8 and Oracle JDK 9 on Mac OS 10.13.2 ... so it may be a problem with the JDK. -> Does this problem also happen, when you comment out all |
Even I comment out all |
Just an idea: Maybe the docker JDK is not a full JDK but a jre-headless? Or the WildFly server is started with the -headless option? But on the other side if the JDK would be headless it should throw an HeadlessException... |
I change a docker container with oracle jdk, and the problem is solved. And the console print out a lot of message about using fallback font LiberationSans for base font Times-Roman ... |
By the way, I want to make a watermark by svg. Is this possible? Since watermark need a transparent svg image to override the pdf contents. |
Adding a watermark should be possible. Do you want to put the watermark in front or in back of the content? The SVG can be transparent, as you can have alpha etc. in a SVG. Try the following:
The header should be drawn before the all other content. For a sample how to define a header you can look here. When the header is drawn no clipping happens, so the header can overlap the page content. Another way (which I mostly use for bills to give the bill the wished cooperate identity) is to merge a PDF into the background of the generated PDF. I.e. postprocess the generated PDF using PDFBox. See e.g. here For your use case just putting the SVG in the header may be the easiest solution. |
@danfickle I think this issue can be closed. |
@rototor Yes, it can be. However which reason cause this exception is still a problem, incomplete jdk or just open jdk it self. By the way, changing the jdk solved me another exception throw by batik. |
Appears to be an upstream issue in RedHat 7.4 which is pulled in by the wildly docker file. |
just use the example in use case, An exception "java.lang.ArrayIndexOutOfBoundsException: 0" is thrown from sun.font.CompositeFont.getSlotFont(CompositeFont.java 351).
I think it is a font problem. So I change the font-family of text to the font I add by "useFont" which work well in general html tag. However, it does not help.
The text was updated successfully, but these errors were encountered: