用于IronSecureDoc的REST API

查克尼特·宾
查克尼特·宾
2024年七月20日
更新 2024年十月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:Valid


[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.

可选请求体参数

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.
match_whole_wordboolTrueAllow partial matches within words be redacted too.
match_caseboolnullMatch case for the words to be redacted.
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.

可选标题

名称
数据类型描述
作者字符串设置PDF元数据的作者属性。
标题字符串设置PDF元数据的标题属性。
主题字符串设置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.

可选标题

名称
数据类型描述
作者字符串设置PDF元数据的作者属性。
标题字符串设置PDF元数据的标题属性。
主题字符串设置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.

可选标题

名称
数据类型描述
作者字符串设置PDF元数据的作者属性。
标题字符串设置PDF元数据的标题属性。
主题字符串设置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] 认证/应用数字签名

端点: http://localhost:8080/v1/document-services/pdfs/certify

描述:通过证书文件(.p12, .pfx)向PDF文档添加认证,以声明其未被篡改。 在请求主体中包含一个 PDF 文件作为pdf_file对象,以及一个证书文件作为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

可选请求体参数

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.
save_as_pdfaboolFalseSave the PDF with PDF/A-3 compliance.
save_as_pdfuaboolFalseSave the PDF with PDF/UA compliance.

可选标题

名称
数据类型描述
作者字符串设置PDF元数据的作者属性。
标题字符串设置PDF元数据的标题属性。
主题字符串设置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 文件作为pdf_file对象,以及一个证书文件作为certificate_file对象。

必需的请求主体参数

NameData TypeDescription
pdf_fileapplication/pdf fileThe PDF file to certify.
signature_image_fileimage/jpeg or image/png fileThe signature image (.png, .jpg, .jpeg) to use for certification. Can be a logo, autograph, etc.
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

sign_specific_pageintSpecify page to apply the image and certificate to. First page is 0. If left empty, only first page will apply.
signature_image_xfloatThe X coordinate of the Rectangle region of the signature image. This starts from the top-left of the page.
signature_image_yfloatThe Y coordinate of the Rectangle region of the signature image. This starts from the top-left of the page.
signature_image_wfloatThe Width of the Rectangle region of the signature image. This starts from the top-left of the page.
signature_image_hfloatThe Height of the Rectangle region of the signature image. This starts from the top-left of the page.

可选请求体参数

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.
save_as_pdfaboolFalseSave the PDF with PDF/A-3 compliance.
save_as_pdfuaboolFalseSave the PDF with PDF/UA compliance.

可选标题

名称
数据类型描述
作者字符串设置PDF元数据的作者属性。
标题字符串设置PDF元数据的标题属性。
主题字符串设置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.

可选请求体参数

名称数据类型默认值描述
user_password字符串null输入PDF的用户密码。如果PDF设有用户密码以授予读取权限,则需要此项。
owner_password字符串null输入PDF的所有者密码。如果PDF设有所有者密码以授予修改权限,则需要此项。

示例:

请求

仅为必填参数:

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 文件。

必需的请求主体参数

名称数据类型描述
pdf_fileapplication/pdf 文件要加密的PDF文件。
allow_extracting_contentbool允许从PDF文件中提取内容。
allow_form_fillingbool允许在生成的PDF中填写表单。
allow_annotationsbool允许在生成的PDF中添加或修改注释。
allow_printingbool允许打印生成的PDF。
allow_modificationsbool允许对生成的PDF进行修改。
new_owner_passwordstring生成PDF的新所有者密码。授予完全访问权限,包括更改权限和密码。

可选请求体参数

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.
new_user_passwordstringnullNew user password for the output PDF. Grants read access and other specified permissions.
save_as_pdfaboolFalseSave the PDF with PDF/A-3 compliance.
save_as_pdfuaboolFalseSave the PDF with PDF/UA compliance.

可选标题

名称
数据类型描述
作者字符串设置PDF元数据的作者属性。
标题字符串设置PDF元数据的标题属性。
主题字符串设置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] 从文档中提取文本

端点: http://localhost:8080/v1/document-services/pdfs/extract

描述:提取文档页面中嵌入的文本。 在请求主体中包含一个PDF文件作为pdf_file对象。

必需的请求主体参数

NameData TypeDescription
pdf_fileapplication/pdf fileThe PDF file to encrypt.

可选请求体参数

名称数据类型默认值描述
user_passwordstringnull输入PDF的用户密码。如果PDF有用户密码以授予读取权限,则需要此密码。
owner_passwordstringnull输入PDF的所有者密码。如果PDF有所有者密码以授权修改,则需要此密码。
specific_pagesarray[int]null可选地指定要应用的页面。如果为空,则应用于所有页面。

示例:

请求

仅为必填参数:

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 方面拥有深厚的专业知识,帮助改进软件并支持客户。他从用户互动中获得的洞察力,有助于提升产品、文档和整体体验。