欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Java 基于Spire.Cloud.SDK for Java在PDF中繪制形狀

 更新時(shí)間:2020年07月24日 17:06:32   作者:E-iceblue  
這篇文章主要介紹了Java 基于Spire.Cloud.SDK for Java在PDF中繪制形狀,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

Spire.Cloud.SDK for Java提供了pdfPathApi接口可用于在PDF文檔中繪制形狀(或圖形),如繪制線條形狀drawLine()、繪制矩形形狀drawRectanglef(),下面將介紹如何通過Java示例和步驟來實(shí)現(xiàn):

一、導(dǎo)入jar文件。(有2種方式)

創(chuàng)建Maven項(xiàng)目程序,通過maven倉庫下載導(dǎo)入。以IDEA為例,新建Maven項(xiàng)目,在pom.xml文件中配置maven倉庫路徑,并指定spire.cloud.sdk的依賴,如下:

<repositories>
 <repository>
  <id>com.e-iceblue</id>
  <name>cloud</name>
  <url>http://repo.e-iceblue.cn/repository/maven-public/</url>
 </repository>
</repositories>

<dependencies>
  <dependency>
   <groupId> cloud </groupId>
   <artifactId>spire.cloud.sdk</artifactId>
   <version>3.5.0</version>
  </dependency>

  <dependency>
  <groupId> com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.8.1</version>
  </dependency>

  <dependency>
   <groupId> com.squareup.okhttp</groupId>
   <artifactId>logging-interceptor</artifactId>
   <version>2.7.5</version>
  </dependency>

  <dependency>
   <groupId> com.squareup.okhttp </groupId>
   <artifactId>okhttp</artifactId>
   <version>2.7.5</version>
  </dependency>

  <dependency>
   <groupId> com.squareup.okio </groupId>
   <artifactId>okio</artifactId>
   <version>1.6.0</version>
  </dependency>

  <dependency>
   <groupId> io.gsonfire</groupId>
   <artifactId>gson-fire</artifactId>
   <version>1.8.0</version>
  </dependency>

  <dependency>
   <groupId>io.swagger</groupId>
   <artifactId>swagger-annotations</artifactId>
   <version>1.5.18</version>
  </dependency>

  <dependency>
   <groupId> org.threeten </groupId>
   <artifactId>threetenbp</artifactId>
   <version>1.3.5</version>
  </dependency>
</dependencies>

完成配置后,點(diǎn)擊“Import Changes” 即可導(dǎo)入所有需要的jar文件。如果使用的是Eclipse,可參考https://cloud.e-iceblue.cn/index.php/tutorials/cloud/webapi/java/maven-spire-cloud-web-api的導(dǎo)入方法。

導(dǎo)入結(jié)果:

二、登錄冰藍(lán)云賬號(hào),創(chuàng)建文件夾,上傳文檔

三、創(chuàng)建應(yīng)用程序,獲取App ID及App Key

四、Java代碼示例

【示例1】繪制線條形狀

import spire.cloud.pdf.sdk.ApiException;
import spire.cloud.pdf.sdk.Configuration;
import spire.cloud.pdf.sdk.api.PdfPathApi;

public class DrawLine {
 //配置賬號(hào)信息
 static String appId = "App ID";
 static String appKey = "App Key";
 static String baseUrl= "https://api.e-iceblue.cn";
 static Configuration configuration = new Configuration(appId, appKey, baseUrl);
 static PdfPathApi pdfPathApi = new PdfPathApi(configuration);

 public static void main(String[] args) throws ApiException {
  String name = "samplefile.pdf";//用于測(cè)試的PDF源文檔
  String outPath = "output/DrawLine.pdf";//結(jié)果文檔路徑(保存在冰藍(lán)云端output文件夾下)
  int pageNumber = 1;//指定需要繪制線段的PDF頁面
  float firstPointfX = 100;//指定線段起始點(diǎn)坐標(biāo)
  float firstPointfY = 150;
  float secondPointfX = 400;
  float secondPointfY = 150;
  String folder = "input";//源文檔輸在文件夾
  String storage = null;//冰藍(lán)云提供的2G免費(fèi)云存儲(chǔ)空間
  String password = null;//源文檔密碼(無密碼設(shè)置為null)

  //調(diào)用方法繪制線條
  pdfPathApi.drawLine(name, outPath, pageNumber, firstPointfX, firstPointfY, secondPointfX, secondPointfY, folder, storage, password);
 }
}

線條繪制效果:

【示例2】繪制矩形形狀

import spire.cloud.pdf.sdk.ApiException;
import spire.cloud.pdf.sdk.Configuration;
import spire.cloud.pdf.sdk.api.PdfPathApi;
import spire.cloud.pdf.sdk.model.RectangleF;

public class DrawRec {
 //配置賬號(hào)信息
 static String appId = "App ID";
 static String appKey = "App Key";
 static String baseUrl= "https://api.e-iceblue.cn";
 static Configuration configuration = new Configuration(appId, appKey, baseUrl);
 static PdfPathApi pdfPathApi = new PdfPathApi(configuration);

 public static void main(String[] args) throws ApiException {
  String name = "samplefile1.pdf";//加載需要添加形狀的PDF源文檔
  String outPath = "output/DrawRectanglef.pdf";//指定結(jié)果文檔路徑(保存在冰藍(lán)云端output文件夾下)
  int pageNumber = 1;//指定需要添加形狀的PDF頁面

  RectangleF rect = new RectangleF();//創(chuàng)建RectangleF類的對(duì)象
  rect.setX(100f);//指定形狀坐標(biāo)
  rect.setY(100f);
  rect.setWidth(350f);//指定形狀寬度、高度
  rect.setHeight(60f);

  String folder = "input";//源文檔所在文件夾
  String storage = null;//冰藍(lán)云提供的2G免費(fèi)存儲(chǔ)空間
  String password = null;//源文檔密碼(無密碼設(shè)置為null)

  //調(diào)用方法繪制矩形
  pdfPathApi.drawRectanglef(name, outPath, pageNumber, rect, folder, storage, password);
 }
}

矩形繪制效果:

到此這篇關(guān)于Java 基于Spire.Cloud.SDK for Java在PDF中繪制形狀的文章就介紹到這了,更多相關(guān)Java 在PDF中繪制形狀內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Java FineReport報(bào)表工具導(dǎo)出EXCEL的四種方式

    Java FineReport報(bào)表工具導(dǎo)出EXCEL的四種方式

    這篇文章主要介紹了Java FineReport報(bào)表工具導(dǎo)出EXCEL的四種方式的相關(guān)資料,需要的朋友可以參考下
    2016-03-03
  • Spring數(shù)據(jù)庫連接池實(shí)現(xiàn)原理深入刨析

    Spring數(shù)據(jù)庫連接池實(shí)現(xiàn)原理深入刨析

    開發(fā)web項(xiàng)目,我們肯定會(huì)和數(shù)據(jù)庫打交道,因此就會(huì)涉及到數(shù)據(jù)庫鏈接的問題。在以前我們開發(fā)傳統(tǒng)的SSM結(jié)構(gòu)的項(xiàng)目時(shí)進(jìn)行數(shù)據(jù)庫鏈接都是通過JDBC進(jìn)行數(shù)據(jù)鏈接,我們每和數(shù)據(jù)庫打一次交道都需要先獲取一次鏈接,操作完后再關(guān)閉鏈接,這樣子效率很低,因此就出現(xiàn)了連接池
    2022-11-11
  • struts2自定義MVC框架

    struts2自定義MVC框架

    這篇文章主要為大家詳細(xì)介紹了struts2如何自定義MVC框架,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • java字符串轉(zhuǎn)數(shù)字及各種數(shù)字轉(zhuǎn)字符串的3種方法

    java字符串轉(zhuǎn)數(shù)字及各種數(shù)字轉(zhuǎn)字符串的3種方法

    這篇文章主要介紹了java字符串轉(zhuǎn)數(shù)字及各種數(shù)字轉(zhuǎn)字符串的3種方法,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-09-09
  • Mybatis游標(biāo)查詢大量數(shù)據(jù)方式

    Mybatis游標(biāo)查詢大量數(shù)據(jù)方式

    這篇文章主要介紹了Mybatis游標(biāo)查詢大量數(shù)據(jù)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-02-02
  • java?JVM-clinit指令實(shí)現(xiàn)原理面試精講

    java?JVM-clinit指令實(shí)現(xiàn)原理面試精講

    這篇文章主要介紹了java?JVM-clinit指令實(shí)現(xiàn)原理面試精講,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10
  • 詳解Java實(shí)現(xiàn)設(shè)計(jì)模式之責(zé)任鏈模式

    詳解Java實(shí)現(xiàn)設(shè)計(jì)模式之責(zé)任鏈模式

    責(zé)任鏈模式是一種行為設(shè)計(jì)模式,允許你將請(qǐng)求沿著處理鏈發(fā)送,然后處理者都可對(duì)其進(jìn)行處理,完成后可以再將其傳遞給下一個(gè)處理者。下面將會(huì)舉例說明什么是責(zé)任鏈模式,責(zé)任鏈模式該如何使用
    2021-06-06
  • 利用Java連接Hadoop進(jìn)行編程

    利用Java連接Hadoop進(jìn)行編程

    這篇文章主要介紹了利用Java連接Hadoop進(jìn)行編程,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,感興趣的小伙伴可以參考一下
    2022-06-06
  • Mybatis 中的insertOrUpdate操作

    Mybatis 中的insertOrUpdate操作

    這篇文章主要介紹了Mybatis 中的insertOrUpdate操作,代碼簡(jiǎn)單易懂,非常不錯(cuò)需要的的朋友參考下
    2016-12-12
  • SpringBoot實(shí)現(xiàn)掃碼登錄的項(xiàng)目實(shí)踐

    SpringBoot實(shí)現(xiàn)掃碼登錄的項(xiàng)目實(shí)踐

    本文主要介紹了SpringBoot實(shí)現(xiàn)掃碼登錄的項(xiàng)目實(shí)踐,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07

最新評(píng)論