如何从Leaflet地图生成矢量图像

时间:2015-12-23 02:50:34

标签: java printing leaflet geoserver html-rendering

我想从类似于GeoServer打印的Leaflet地图生成图像。 一些层来自GeoServer WMS,基础层是OSM。

String link="http://192.168.1.240:8080/geoserver/capas_geodir/wms?service=WMS&version=1.1.0&request=GetMap&layers=capas_geodir:nse&styles=&bbox=-77.1957625759999,-12.3132450279999,-76.6682149649999,-11.727164139&width=460&height=512&srs=EPSG:4326&format=image/png";
URL url=new URL(link);
Image image = ImageIO.read(url);
//RenderedImage img = ImageIO.read(url);
File outputfile = new File("e:/image.png");
Font catFont = new Font(Font.FontFamily.TIMES_ROMAN, 18,  Font.BOLD);
Font redFont = new Font(Font.FontFamily.TIMES_ROMAN, 12,  Font.NORMAL, BaseColor.RED);
try {
    Document document = new Document();
    document.setPageSize(com.itextpdf.text.PageSize.A4.rotate());
    document.setMargins(20, 20, 20, 50);
    PdfWriter.getInstance(document, new FileOutputStream("E:/test.pdf"));
    document.open();
    PdfPTable pdfTable = new PdfPTable(1);
    com.itextpdf.text.Image imagepdf
                 =com.itextpdf.text.Image.getInstance(image,Color.white);
    //imagepdf.scalePercent(20f);
    PdfPCell cell=null;
    cell=new PdfPCell(new Phrase("SIGUT"));
    cell.setBorderColor(new BaseColor(15, 15, 15));
    pdfTable.addCell(cell);
    cell= new PdfPCell();
    cell.setImage(imagepdf);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorderColor(new BaseColor(15, 15, 15));
    pdfTable.addCell(cell);
    document.add(pdfTable);
    document.close();
    System.out.println( "PDF Created!" );
} catch (Exception e) {
    System.out.println(e.getMessage());
}

如何使用基础层生成图像?

enter image description here

0 个答案:

没有答案