IronSecureDoc 的 REST API

查克尼思·賓
查克尼思·賓
2024年7月20日
已更新 2024年10月20日
分享:
This article was translated from English: Does it need improvement?
Translated
View the article in English

這是您 IronSecureDoc 實例的 REST API 參考文件。 本教程假設您已經有一個運行中的容器實例,如果您希望開始使用,請按照我們的指南。

跳至功能:

[GET] 健康檢查

端點: http://localhost:8080/v1/document-services/ping

健康檢查端點以驗證伺服器是否正在運行。

回應:200 OK:pong


[GET] 檢查許可證

端點: http://localhost:8080/v1/document-services/check-license

驗證許可證的有效性。

回應:200 OK:有效


[POST] 抹除文字

端點:http://localhost:8080/v1/document-services/pdfs/redact-text

使用真正的刪減功能隱藏 PDF 格式文件中的敏感詞。 在請求主體中將 PDF 文件作為 pdf_file 對象包含。

所需請求正文參數

NameData TypeDescription
pdf_fileapplication/pdf fileThe PDF file to redact.
words_to_redactarray[string]An array of words to be redacted from the document.

選擇性請求主體參數

名稱資料類型預設值描述
user_passwordstringnull用於輸入 PDF 的用戶密碼。如果 PDF 有用戶密碼以授予讀取權限,則為必填。
owner_passwordstringnull用於輸入 PDF 的擁有者密碼。如果 PDF 有擁有者密碼以授予進行修改的權限,則為必填。
specific_pagesarray[int]null可選地指定要應用的頁面。如果留空,將應用於所有頁面。
draw_black_boxboolTrue在被編輯的文字區域上繪製黑框。
match_whole_wordboolTrue允許在單詞中進行部分匹配編輯。
match_caseboolnull匹配要編輯文字的大小寫。
overlay_textstringnull如果您希望在編輯區域中顯示疊加文字(例如文字或符號),請在此設置。如果不設置,將使用空白字符。
save_as_pdfaboolFalse將 PDF 保存為符合 PDF/A-3 標準。
save_as_pdfuaboolFalse將 PDF 保存為符合 PDF/UA 標準。

可選標頭

名稱資料類型描述
authorstring設置 PDF 中的元數據作者屬性。
titlestring設置 PDF 中的元數據標題屬性。
subjectstring設置 PDF 中的元數據主題屬性。

範例:

請求

僅限必填參數:

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/redact-text' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'words_to_redact="pdf"' \
  -F 'draw_black_box=true' \
  -F 'match_whole_word=true' \
  -F 'match_case=true' \
CURL

所有必需和可選參數:

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/redact-text' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'words_to_redact="word1"' \
  -F 'words_to_redact="word2"' \
  -F 'draw_black_box=true' \
  -F 'match_whole_word=true' \
  -F 'match_case=true' \
  -F 'user_password="password"' \
  -F 'owner_password="5yug2RT45th32h78"' \
  -F 'overlay_text="REDACTED"' \
  -F 'specific_pages=0' \
  -F 'specific_pages=1' \
  -F 'save_as_pdfa=false' \
  -F 'save_as_pdfua=false' \
CURL

回應

  • 200 OK 附上編輯過的 PDF 文件。

[POST] 編輯正則表達式

端點: http://localhost:8080/v1/document-services/pdfs/redact-regular-expression

使用真正的修訂功能隱藏PDF格式文件中的敏感正則表達式匹配項(如日期、名稱或模式)。 在請求主體中將 PDF 文件作為 pdf_file 對象包含。

所需請求正文參數

NameData TypeDescription
pdf_fileapplication/pdf fileThe PDF file to redact.
regular_expressionstringRegular Expression from which matching cases will be redacted from the document.

選擇性請求主體參數

NameData TypeDefaultDescription
user_passwordstringnullUser password for the input PDF. Required if the PDF has a user password to grant read access.
owner_passwordstringnullOwner password for the input PDF. Required if the PDF has an owner password to grant access to make modifications.
specific_pagesarray[int]nullOptionally specify pages to apply to. If left empty, all pages will apply.
draw_black_boxboolTrueHave a Black Box drawn over redacted text areas.
overlay_textstringnullIf your prefer an Overlay Text on the redaction area such as words or symbols, set them here. If not set, a blank character will be used.
save_as_pdfaboolFalseSave the PDF with PDF/A-3 compliance.
save_as_pdfuaboolFalseSave the PDF with PDF/UA compliance.

可選標頭

名稱資料類型描述
authorstring設置 PDF 中的元數據作者屬性。
titlestring設置 PDF 中的元數據標題屬性。
subjectstring設置 PDF 中的元數據主題屬性。

範例:

請求

僅限必填參數:

curl -X 'POST' \
  'http://localhost:8080/v1/document-services/pdfs/redact-regular-expression' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'regular_expression="[0-9]"' \
  -F 'draw_black_box=true' \
CURL

所有必需和可選參數:

curl -X 'POST' \
  'http://localhost:8080/v1/document-services/pdfs/redact-regular-expression' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'regular_expression="[0-9]"' \
  -F 'draw_black_box=true' \
  -F 'user_password="password"' \
  -F 'owner_password="5yug2RT45th32h78"' \
  -F 'overlay_text="%2A"' \
  -F 'specific_pages=0' \
  -F 'specific_pages=1' \
  -F 'save_as_pdfa=false' \
  -F 'save_as_pdfua=false' \
CURL

回應

  • 200 OK 附上編輯過的 PDF 文件。

[POST] 擦除區域

端點: http://localhost:8080/v1/document-services/pdfs/redact-region

描述:使用真正的修訂功能隱藏 PDF 文件中特定區域的敏感文字。 在請求主體中將 PDF 文件作為 pdf_file 對象包含。

所需請求正文參數

NameData TypeDescription
pdf_fileapplication/pdf fileThe PDF file to redact.
region_to_redact_xfloatX coordinate of the region to redact, starting from the bottom-left of the page.
region_to_redact_yfloatY coordinate of the region to redact, starting from the bottom-left of the page.
region_to_redact_wfloatWidth of the region to redact, starting from the specified X coordinate.
region_to_redact_hfloatHeight of the region to redact, starting from the specified Y coordinate.

選擇性請求主體參數

NameData TypeDefaultDescription
user_passwordstringnullUser password for the input PDF. Required if the PDF has a user password to grant read access.
owner_passwordstringnullOwner password for the input PDF. Required if the PDF has an owner password to grant access to make modifications.
specific_pagesarray[int]nullOptionally specify pages to apply to. If left empty, all pages will apply.
draw_black_boxboolTrueHave a Black Box drawn over redacted text areas.
save_as_pdfaboolFalseSave the PDF with PDF/A-3 compliance.
save_as_pdfuaboolFalseSave the PDF with PDF/UA compliance.

可選標頭

名稱資料類型描述
authorstring設置 PDF 中的元數據作者屬性。
titlestring設置 PDF 中的元數據標題屬性。
subjectstring設置 PDF 中的元數據主題屬性。

範例:

請求

僅限必填參數:

curl -X 'POST' \
  'http://localhost:8080/v1/document-services/pdfs/redact-region' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'region_to_redact_x=100' \
  -F 'region_to_redact_y=150' \
  -F 'region_to_redact_w=500' \
  -F 'region_to_redact_h=400' \
CURL

所有必需和可選參數:

curl -X 'POST' \
  'http://localhost:8080/v1/document-services/pdfs/redact-region' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'user_password="password"' \
  -F 'owner_password="5yug2RT45th32h78"' \
  -F 'region_to_redact_x=100' \
  -F 'region_to_redact_y=150' \
  -F 'region_to_redact_w=500' \
  -F 'region_to_redact_h=400' \
  -F 'specific_pages=0' \
  -F 'specific_pages=1' \
  -F 'save_as_pdfa=false' \
  -F 'save_as_pdfua=false' \
CURL

回應

  • 200 OK 附上編輯過的 PDF 文件。

[POST] 認證 / 應用數位簽名

Endpoint:http://localhost:8080/v1/document-services/pdfs/certify

描述:使用證書文件(.p12, .pfx)為 PDF 文件添加認證,以確保其未被篡改。 在請求正文中包含一個作為pdf_file對象的PDF檔案,以及一個作為certificate_file對象的證書檔案。

所需請求正文參數

NameData TypeDescription
pdf_fileapplication/pdf fileThe PDF file to certify.
certificate_fileapplication/x-pkcs12 fileThe certificate file (.p12, .pfx) to use for certification.
certificate_passwordstringPassword for the provided certificate file.
certificate_permissionsint
certificate_permissions valuePermissions
1No Changes Allowed. Any further document changes will invalidate the signature.
2Only Additional Signatures and Form Filling Allowed.
3Only AdditionalSignatures, Form Filling, and Annotations Allowed

選擇性請求主體參數

名稱資料類型預設值描述
user_passwordstringnull輸入 PDF 的用戶密碼。如果 PDF 有用戶密碼以授予讀取權限,則必須提供。
owner_passwordstringnull輸入 PDF 的擁有者密碼。如果 PDF 有擁有者密碼以授予修改權限,則必須提供。
save_as_pdfaboolFalse將 PDF 保存為符合 PDF/A-3。
save_as_pdfuaboolFalse將 PDF 保存為符合 PDF/UA。

可選標頭

名稱資料類型描述
authorstring設置 PDF 中的元數據作者屬性。
titlestring設置 PDF 中的元數據標題屬性。
subjectstring設置 PDF 中的元數據主題屬性。

範例:

請求

僅限必填參數:

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/certify' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'certificate_file=@sample.pfx;type=application/x-pkcs12' \
  -F 'certificate_password="p4ssw0rd"' \
  -F 'certificate_permissions=1' \
CURL

所有必需和可選參數:

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/certify' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'certificate_file=@sample.pfx;type=application/x-pkcs12' \
  -F 'certificate_password="p4ssw0rd"' \
  -F 'certificate_permissions=1' \
  -F 'user_password="password"' \
  -F 'owner_password="5yug2RT45th32h78"' \
  -F 'save_as_pdfa=false' \
  -F 'save_as_pdfua=false' \
CURL

回應

  • 200 OK,附有認證的 PDF 檔案。

[POST] 使用簽名和證書簽署文件

端點:http://localhost:8080/v1/document-services/pdfs/sign

描述:在 PDF 文件中添加一張圖片和驗證證書,確保該圖片未經篡改,使用證書文件(.p12, .pfx)。 在請求正文中包含一個作為pdf_file對象的PDF檔案,以及一個作為certificate_file對象的證書檔案。

所需請求正文參數

pdf_file
NameData TypeDescription

選擇性請求主體參數

名稱資料類型預設值描述
user_passwordstringnull輸入PDF的使用者密碼。如果PDF具有使用者密碼以授予讀取權限,則必需。
owner_passwordstringnull輸入PDF的所有者密碼。如果PDF具有所有者密碼以授予修改權限,則必需。
specific_pagesarray[int]null可選指定要應用的頁面。如果留空,則會應用於所有頁面。
save_as_pdfaboolFalse以PDF/A-3相容性儲存PDF。
save_as_pdfuaboolFalse以PDF/UA相容性儲存PDF。

可選標頭

名稱資料類型描述
authorstring設置 PDF 中的元數據作者屬性。
titlestring設置 PDF 中的元數據標題屬性。
subjectstring設置 PDF 中的元數據主題屬性。

範例:

請求

僅限必填參數:

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/sign' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'signature_image_file=@autograph.png;type=image/png' \
  -F 'certificate_file=@sample.pfx;type=application/x-pkcs12' \
  -F 'certificate_password="p4ssw0rd"' \
  -F 'certificate_permissions=1' \
  -F 'sign_specific_page=0' \
  -F 'signature_image_x=100' \
  -F 'signature_image_y=150' \
  -F 'signature_image_w=500' \
  -F 'signature_image_h=400' \
CURL

所有必需和可選參數:

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/sign' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'certificate_file=@sample.pfx;type=application/x-pkcs12' \
  -F 'certificate_password="p4ssw0rd"' \
  -F 'certificate_permissions=0' \
  -F 'user_password="password"' \
  -F 'owner_password="5yug2RT45th32h78"' \
  -F 'save_as_pdfa=false' \
  -F 'save_as_pdfua=false' \
  -F 'sign_specific_page=0' \
  -F 'signature_image_x=100' \
  -F 'signature_image_y=150' \
  -F 'signature_image_w=500' \
  -F 'signature_image_h=400' \
CURL

回應

  • 200 OK,附有認證的 PDF 檔案。

[POST] 驗證簽名

端點: http://localhost:8080/v1/document-services/pdfs/verify-signatures

描述:驗證所提供的使用者和擁有者密碼是否對pdf_file有效

所需請求正文參數

NameData TypeDescription
pdf_fileapplication/pdf fileThe PDF file to encrypt.

選擇性請求主體參數

NameData TypeDefaultDescription
user_passwordstringnullUser password for the input PDF. Required if the PDF has a user password to grant read access.
owner_passwordstringnullOwner password for the input PDF. Required if the PDF has an owner password to grant access to make modifications.

範例:

請求

僅限必填參數:

curl -X POST 'https://api.securedoc.com/v1/document-services/pdfs/verify-signatures' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
YAML

所有必需和可選參數:

curl -X POST 'https://api.securedoc.com/v1/document-services/pdfs/verify-signatures' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'user_password="password"' \
  -F 'owner_password="5yug2RT45th32h78"' \
YAML

回應

  • 如果有簽名且全部有效則返回 200 OK
  • 如果沒有簽名或至少一個簽名無效,則返回 400 BadRequest 結果。

[POST] 加密 / 添加密碼和權限

端點:http://localhost:8080/v1/document-services/pdfs/encrypt

描述:透過使用者和擁有者密碼加密PDF文件,增加一層安全性。 在請求主體中包含一個作為 pdf_file 對象的 PDF 文件。

所需請求正文參數

NameData TypeDescription
pdf_fileapplication/pdf fileThe PDF file to encrypt.
allow_extracting_contentboolAllow the extraction of content from the PDF file.
allow_form_fillingboolAllow the filling of forms in the resulting PDF.
allow_annotationsboolAllow the addition or modification of annotations in the resulting PDF.
allow_printingboolAllow printing of the resulting PDF.
allow_modificationsboolAllow modifications to the resulting PDF.
new_owner_passwordstringNew owner password for the output PDF. Grants full access, including changing permissions and passwords.

選擇性請求主體參數

名稱資料類型預設值説明
user_passwordstringnull輸入 PDF 的用戶密碼。如果 PDF 設有用戶密碼以授予讀取權限,則此項為必填。
owner_passwordstringnull輸入 PDF 的擁有者密碼。如果 PDF 設有擁有者密碼以授予修改權限,則此項為必填。
new_user_passwordstringnull輸出 PDF 的新用戶密碼。授予讀取權限和其他指定權限。
save_as_pdfaboolFalse以 PDF/A-3 標準存儲 PDF。
save_as_pdfuaboolFalse以 PDF/UA 標準存儲 PDF。

可選標頭

名稱資料類型描述
authorstring設置 PDF 中的元數據作者屬性。
titlestring設置 PDF 中的元數據標題屬性。
subjectstring設置 PDF 中的元數據主題屬性。

範例:

請求

僅限必填參數:

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/encrypt' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'allow_extracting_content=true' \
  -F 'allow_form_filling=true' \
  -F 'allow_annotations=true' \
  -F 'allow_printing=true' \
  -F 'allow_modifications=false' \
CURL

所有必需和可選參數:

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/encrypt' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'allow_extracting_content=true' \
  -F 'allow_form_filling=true' \
  -F 'allow_annotations=true' \
  -F 'allow_printing=true' \
  -F 'allow_modifications=false' \
  -F 'user_password="password"' \
  -F 'owner_password="5yug2RT45th32h78"' \
  -F 'new_user_password="p4ssw0rd"' \
  -F 'save_as_pdfa=false' \
  -F 'save_as_pdfua=false' \
CURL

回應

  • 200 OK並附有加密的PDF檔案。

[POST] 從文件中提取文本

Endpoint: http://localhost:8080/v1/document-services/pdfs/extract

描述:提取嵌入在文檔頁面中的文本。 在請求主體中將 PDF 文件作為 pdf_file 對象包含。

所需請求正文參數

NameData TypeDescription
pdf_fileapplication/pdf fileThe PDF file to encrypt.

選擇性請求主體參數

NameData TypeDefaultDescription
user_passwordstringnullUser password for the input PDF. Required if the PDF has a user password to grant read access.
owner_passwordstringnullOwner password for the input PDF. Required if the PDF has an owner password to grant access to make modifications.
specific_pagesarray[int]nullOptionally specify pages to apply to. If left empty, all pages will apply.

範例:

請求

僅限必填參數:

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/extract' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
CURL

所有必需和可選參數:

curl -X POST 'http://localhost:8080/v1/document-services/pdfs/extract' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'user_password="password"' \
  -F 'owner_password="5yug2RT45th32h78"' \
  -F 'specific_pages=0' \
  -F 'specific_pages=1' \
CURL

回應

  • 200 OK 與提取的文本作為回應。

[POST] 驗證文件密碼

端點: http://localhost:8080/v1/document-services/pdfs/verify-password

描述:驗證所提供的使用者和擁有者密碼是否對pdf_file有效

所需請求正文參數

NameData TypeDescription
pdf_fileapplication/pdf fileThe PDF file.
user_passwordstringUser password for the input PDF. Required if the PDF has a user password to grant read access.
owner_passwordstringOwner password for the input PDF.

範例:

請求

僅限必填參數:

curl -X POST 'https://api.securedoc.com/v1/document-services/pdfs/verify-password' \
  -H 'accept: */*' \
  -H 'author: Iron Software 
 IRONSECUREDOC' \
  -H 'title: WEBSITE DEMO 2024' \
  -H 'subject: DEMO EXAMPLE' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@sample.pdf;type=application/pdf' \
  -F 'user_password="password"' \
  -F 'owner_password="5yug2RT45th32h78"' \
YAML

回應

  • 200 OK
查克尼思·賓
軟體工程師
Chaknith 致力於 IronXL 和 IronBarcode。他在 C# 和 .NET 方面擁有豐富的專業知識,協助改進軟體並支持客戶。他從用戶互動中獲得的洞察力有助於提高產品、文檔和整體體驗。