How do I print the output to PDF?

0 votes
asked May 23, 2018 in Bug by anonymous
edited May 23, 2018

This is the output from my Terminal application, when I tried to produce a PDF image from my PlantUML script.

java    -jar    /Applications/apps/graphics/plantuml.1.2018.6.jar    *.uml    -tpdf

java.lang.ClassNotFoundException: org.apache.batik.apps.rasterizer.SVGConverter

    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

    at java.lang.Class.forName0(Native Method)

    at java.lang.Class.forName(Class.java:264)

    at net.sourceforge.plantuml.pdf.PdfConverter.convert(PdfConverter.java:53)

    at net.sourceforge.plantuml.UmlDiagram.exportDiagramInternalPdf(UmlDiagram.java:359)

    at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:220)

    at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:135)

    at net.sourceforge.plantuml.PSystemUtils.exportDiagramsCuca(PSystemUtils.java:236)

    at net.sourceforge.plantuml.PSystemUtils.exportDiagrams(PSystemUtils.java:92)

    at net.sourceforge.plantuml.SourceFileReaderAbstract.getGeneratedImages(SourceFileReaderAbstract.java:153)

    at net.sourceforge.plantuml.Run.manageFileInternal(Run.java:434)

    at net.sourceforge.plantuml.Run.processArgs(Run.java:345)

    at net.sourceforge.plantuml.Run.manageAllFiles(Run.java:315)

    at net.sourceforge.plantuml.Run.main(Run.java:163)

Exception in thread "main" java.lang.UnsupportedOperationException

    at net.sourceforge.plantuml.pdf.PdfConverter.convert(PdfConverter.java:72)

    at net.sourceforge.plantuml.UmlDiagram.exportDiagramInternalPdf(UmlDiagram.java:359)

    at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:220)

    at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:135)

    at net.sourceforge.plantuml.PSystemUtils.exportDiagramsCuca(PSystemUtils.java:236)

    at net.sourceforge.plantuml.PSystemUtils.exportDiagrams(PSystemUtils.java:92)

    at net.sourceforge.plantuml.SourceFileReaderAbstract.getGeneratedImages(SourceFileReaderAbstract.java:153)

    at net.sourceforge.plantuml.Run.manageFileInternal(Run.java:434)

    at net.sourceforge.plantuml.Run.processArgs(Run.java:345)

    at net.sourceforge.plantuml.Run.manageAllFiles(Run.java:315)

    at net.sourceforge.plantuml.Run.main(Run.java:163)


1 Answer

0 votes
answered May 23, 2018 by plantuml (294,960 points)
Hi,

You should follow instructions there http://plantuml.com/pdf

Regards,
commented May 23, 2018 by anonymous
I tried to do that, but it still does not work.

I placed all the JAR files and the PlantUML script in the same directory, and I still get the same error.

See below for the transcript from the Terminal



Go Trojans >ls -al
total 30976
drwxr-xr-x  13 zhiyang  admin      416 May 23 10:51 .
drwxr-xr-x   6 zhiyang  admin      192 May 23 10:26 ..
-rw-r--r--@  1 zhiyang  admin     6148 May 23 10:48 .DS_Store
-rw-r--r--@  1 zhiyang  staff    86038 May 23 10:31 avalon-framework-4.2.0.jar
-rw-r--r--@  1 zhiyang  staff  3318083 May 23 10:32 batik-all-1.7.jar
-rw-r--r--@  1 zhiyang  staff    83613 May 23 10:33 commons-io-1.3.1.jar
-rw-r--r--@  1 zhiyang  staff    38015 May 23 10:34 commons-logging-1.0.4.jar
-rw-r--r--@  1 zhiyang  admin  4292943 Apr  3  2017 fop.jar
-rw-r--r--@  1 zhiyang  staff  7242223 May 22 17:14 plantuml.1.2018.6.jar
-rw-r--r--   1 zhiyang  admin        0 May 23 10:51 sw-arch.pdf
-rw-r--r--@  1 zhiyang  admin     1695 May 22 18:05 sw-arch.uml
-rw-r--r--@  1 zhiyang  staff    85686 May 23 10:36 xml-apis-ext-1.3.04.jar
-rw-r--r--@  1 zhiyang  staff   569113 May 23 10:44 xmlgraphics-commons-1.4.jar
Go Trojans >java -jar plantuml.1.2018.6.jar -tpdf sw-arch.uml
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.sourceforge.plantuml.pdf.PdfConverter.convert(PdfConverter.java:69)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramInternalPdf(UmlDiagram.java:359)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:220)
    at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:135)
    at net.sourceforge.plantuml.PSystemUtils.exportDiagramsCuca(PSystemUtils.java:236)
    at net.sourceforge.plantuml.PSystemUtils.exportDiagrams(PSystemUtils.java:92)
    at net.sourceforge.plantuml.SourceFileReaderAbstract.getGeneratedImages(SourceFileReaderAbstract.java:153)
    at net.sourceforge.plantuml.Run.manageFileInternal(Run.java:434)
    at net.sourceforge.plantuml.Run.processArgs(Run.java:345)
    at net.sourceforge.plantuml.Run.manageAllFiles(Run.java:315)
    at net.sourceforge.plantuml.Run.main(Run.java:163)
Caused by: java.lang.NoClassDefFoundError: org/apache/batik/bridge/FontFamilyResolver
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.apache.batik.apps.rasterizer.DestinationType.getTranscoder(Unknown Source)
    at org.apache.batik.apps.rasterizer.SVGConverter.execute(Unknown Source)
    ... 15 more
Caused by: java.lang.ClassNotFoundException: org.apache.batik.bridge.FontFamilyResolver
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 31 more
Exception in thread "main" java.lang.UnsupportedOperationException
    at net.sourceforge.plantuml.pdf.PdfConverter.convert(PdfConverter.java:72)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramInternalPdf(UmlDiagram.java:359)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:220)
    at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:135)
    at net.sourceforge.plantuml.PSystemUtils.exportDiagramsCuca(PSystemUtils.java:236)
    at net.sourceforge.plantuml.PSystemUtils.exportDiagrams(PSystemUtils.java:92)
    at net.sourceforge.plantuml.SourceFileReaderAbstract.getGeneratedImages(SourceFileReaderAbstract.java:153)
    at net.sourceforge.plantuml.Run.manageFileInternal(Run.java:434)
    at net.sourceforge.plantuml.Run.processArgs(Run.java:345)
    at net.sourceforge.plantuml.Run.manageAllFiles(Run.java:315)
    at net.sourceforge.plantuml.Run.main(Run.java:163)
Go Trojans >
commented May 23, 2018 by anonymous
I also noticed this on the web page that you directed me to.

Or format="pdf" in the ant task:


<!-- task definition -->
<taskdef name="plantuml" classname="net.sourceforge.plantuml.ant.PlantUmlTask" classpath="plantuml.jar" />
<!-- process diagram.txt file -->
<target name="images">
<plantuml format="pdf">
<fileset file="diagram.txt" />
</plantuml>
</target>

How do I change the format="pdf" in the ant task?

Can you please kindly let me know how and why does Ant play a role in generating PDF output from PlantUML scripts?

Thank you so much, and have a great day!
commented May 23, 2018 by plantuml (294,960 points)
You don't seem to have exactly the same files as in https://www.dropbox.com/s/p68jqt29x3asppv/batikAndFop.zip?dl=0

81961 avalon-framework-4.2.0.jar
3318083 batik-all-1.7.jar
83613 commons-io-1.3.1.jar
38015 commons-logging-1.0.4.jar
3079811 fop.jar
7242223 plantuml.1.2018.6.jar
7530523 plantuml.jar
85686 xml-apis-ext-1.3.04.jar
569113 xmlgraphics-commons-1.4.jar

avalon-framework-4.2.0.jar and fop.jar don't have the same size. Can you try with https://www.dropbox.com/s/p68jqt29x3asppv/batikAndFop.zip?dl=0 to see it it works better ?
Thanks!
commented May 23, 2018 by anonymous
After I downloaded the suggested ZIP file containing the JAR files, I tried to unzip the file.

However, I cannot unzip them successfully.

Here are screenshots of the problem.

https://github.com/eda-ricercatore/bibtex-analytics/blob/master/notes/report/pics/cannot-unzip-jar-file-terminal.jpg

https://github.com/eda-ricercatore/bibtex-analytics/blob/master/notes/report/pics/cannot-unzip-jar-files-os.jpg

Can you please kindly let me know what else can I do to resolve the problem?

Thank you so much, and have a good day! Ciao!
commented May 23, 2018 by plantuml (294,960 points)
Use the following file instead http://beta.plantuml.net/batikAndFop2.zip
commented May 23, 2018 by anonymous
Thank you so much for helping me. It now works.

However, I encountered a very long error message after I used it for the first time; subsequent usage of the tool caused no problems.

See https://github.com/eda-ricercatore/bibtex-analytics/blob/master/notes/report/pics/old/error-with-solution.txt for the Terminal transcript.
commented May 23, 2018 by plantuml (294,960 points)
Try the last beta http://beta.plantuml.net/plantuml.jar (not tested)

or use the following command line:
java -Dlog4j.debug=false plantuml.jar -tpdf test.txt
commented Mar 1, 2019 by Mindavi
http://archive.apache.org/dist/xmlgraphics/fop/binaries/ has packages containing all the files needed, if you want to get them from the source. You need to choose fop v1.0. Unzip the file and go into the lib folder for all the libraries, in the build folder you can find fop.jar.
...