package page.image;

import java.awt.Graphics2D;
import java.io.IOException;

import org.wikiwebserver.handler.http.HTTPHandler;
import org.wikiwebserver.handler.http.interfaces.*;
import org.wikiwebserver.util.image.PDFHelper;

public class PDFExample extends CacheableExample implements HTTPResponder {
	
    public void init(HTTPHandler conn) throws IOException {
        conn.getResponse().getHeaders().set("Content-Type", "application/pdf");
    }
    
    public Object respond(HTTPHandler conn) throws IOException {
        
        PDFHelper pdfHelper = new PDFHelper(200, 200, conn.getOutputStream());
        Graphics2D g2d = pdfHelper.createGraphics();
        
        // Use the parent paint method to draw the example        
        super.paint(g2d);

        pdfHelper.writeImageData();
        
        return null;
    }
}