Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package pl.umk.mat.faramir.beamer; import java.io.IOException; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation; import org.apache.pdfbox.rendering.PDFRenderer; import org.apache.pdfbox.rendering.PageDrawer; import org.apache.pdfbox.rendering.PageDrawerParameters; /** * * @author faramir */ public class PdfRenderer extends PDFRenderer { public PdfRenderer(PDDocument document) throws IOException { super(document); } @Override protected PageDrawer createPageDrawer(PageDrawerParameters parameters) throws IOException { return new PdfPageDrawer(parameters); } private static class PdfPageDrawer extends PageDrawer { PdfPageDrawer(PageDrawerParameters parameters) throws IOException { super(parameters); } // // @Override // public void drawPage(Graphics g, PDRectangle pageSize) throws IOException { // Graphics2D g2 = (Graphics2D) g; // g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); // g2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); // g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); // g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); // g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); // g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // super.drawPage(g, pageSize); // } /** * Custom annotation rendering. */ @Override public void showAnnotation(PDAnnotation annotation) throws IOException { // save saveGraphicsState(); // 35% alpha getGraphicsState().setNonStrokeAlphaConstants(0.35); super.showAnnotation(annotation); // restore restoreGraphicsState(); } } }