Created
April 12, 2019 08:30
-
-
Save vandeseer/46271f3e103e336b609edca4234dd4af to your computer and use it in GitHub Desktop.
Minimal example for creating an IllegalArgumentException because symbol is not available in font
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package easytaaable; | |
import static org.apache.pdfbox.pdmodel.font.PDType1Font.SYMBOL; | |
import java.io.IOException; | |
import org.apache.pdfbox.pdmodel.PDDocument; | |
import org.apache.pdfbox.pdmodel.PDPage; | |
import org.apache.pdfbox.pdmodel.PDPageContentStream; | |
import org.apache.pdfbox.pdmodel.common.PDRectangle; | |
public class PDFBoxFontEncoding { | |
public static void main(String[] args) throws IOException { | |
try (final PDDocument document = new PDDocument()) { | |
PDPage page = new PDPage(PDRectangle.A4); | |
document.addPage(page); | |
try (PDPageContentStream contentStream = new PDPageContentStream(document, page)) { | |
contentStream.beginText(); | |
contentStream.setFont( SYMBOL, 12 ); | |
contentStream.newLineAtOffset( 100, 700 ); | |
contentStream.showText( "S" ); | |
contentStream.endText(); | |
} | |
document.save("fontIssue.pdf"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment