有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何从单张图生成矢量图像

我想从类似GeoServer print的传单地图生成图像。 某些图层来自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) 个答案