Skip to content

Instantly share code, notes, and snippets.

@daquinoaldo
Last active November 7, 2022 10:26
Show Gist options
  • Save daquinoaldo/c670d5d8bfeed886598e1078d7171e87 to your computer and use it in GitHub Desktop.
Save daquinoaldo/c670d5d8bfeed886598e1078d7171e87 to your computer and use it in GitHub Desktop.
PDF doclet: export JavaDoc in PDF

PDF doclet: export JavaDoc in PDF

  1. Download PDFDoclet from SourceForge.
  2. Edit pdfdoclet.sh setting correctly
  • PATH: the Java bin path
  • DOCLET_PATH: the path to the downloaded PDFDoclet JAR
  • SRC: the path to your source code containing the JavaDoc
  • PACKAGES: the list of all the packages in your source code
  • OUTPUT_NAME: optionally, the output name of the generated pdf (the directory must exists).
  1. Edit pdfdoclet.config changing api.title (the title of the first page of the JavaDoc) and api.author (your name)
# Defines the title on the title page.
api.title=PDF Doclet - export JavaDoc in PDF
# Defines the author text on the title page.
api.author=Aldo D'Aquino
# Prints @author tags if set to "yes".
tag.author=yes
# Prints @version tags if set to "yes".
tag.version=yes
# Prints @since tags if set to "yes".
tag.since=yes
# Show the Summary Tables if set to "yes".
summary.table=yes
# Encrypts the document if set to "yes".
encrypted=yes
# The following property is ignored
# if "encrypted" is not set to yes.
allow.printing=yes
# Creates hyperlinks if set to "yes".
# For print documents, use "no", so
# there will be no underscores.
create.links=yes
# Creates an alphabetical index of all
# classes and members at the end of the
# document if set to "yes".
create.index=yes
# Creates a navigation frame (or PDF
# outline tree) if set to "yes".
create.frame=yes
# Creates a title page at the beginning
# of the document if set to "yes".
api.title.page=yes
# Defines packages whose classes should not
# be printed fully qualified. For example, every
# Java developer probably knows that "String" is in
# the "java.lang" package, so instead of wasting
# page spage, just get rid of that package qualifier:
# dontspec=java.lang
dontspec=java.lang,java.io,java.util
#!/bin/sh
# CONFIGS
PATH="/usr/local/java/j2se/bin" # path of Java bin folder
DOCLET="com.tarsec.javadoc.pdfdoclet.PDFDoclet" # do not change
DOCLET_PATH="pdfdoclet-1.0.0-all.jar" # path of the pdfdoclet jar
SRC="myproject/src" # path of the source code
PACKAGES="com.mydomain.package1.api com.mydomain.package1.gui com.mydomain.package2" # list of packages of your code separated by a space
OUTPUT_NAME="docs/javadoc.pdf" # name and path of the pdf output file
CFG="pdfdoclet.configs"
# RUN
javadoc -doclet $DOCLET -docletpath $DOCLET_PATH -pdf $OUTPUT_NAME -config $CFG -sourcepath $SRC $PACKAGES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment