More Features
Watermark
Add Text Watermark
With the Add Watermark tool, you can add text watermarks to your PDFs. The following examples show how to upload a PDF file and run the Add Watermark feature using Java, PHP, C#, Python, and Swift programming languages. Then, output a PDF file.
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);
// Create a task
// Create an example of a PDF AddWatermark task
CPDFCreateTaskResult result = client.createTask(CPDFDocumentEditorEnum.ADD_WATERMARK);
// Get a task id
String taskId = result.getTaskId();
// File handling parameter settings
CPDFAddWatermarkParameter fileParameter = new CPDFAddWatermarkParameter();
fileParameter.setType("text");
fileParameter.setScale("1");
fileParameter.setOpacity("0.5");
fileParameter.setRotation("0.785");
fileParameter.setTargetPages("1-2");
fileParameter.setVertalign("center");
fileParameter.setHorizalign("left");
fileParameter.setXoffset("100");
fileParameter.setYoffset("100");
fileParameter.setContent("test");
fileParameter.setTextColor("#59c5bb");
fileParameter.setFullScreen("1");
fileParameter.setHorizontalSpace("10");
fileParameter.setVerticalSpace("10");
// Upload files
client.uploadFile(new File("test.pdf"), taskId, fileParameter);
// Execute task
client.executeTask(taskId);
// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.getTaskInfo(taskId);
// Create a client
$client = new CPDFClient('public_key', 'secret_key');
// Create a task
// Create an example of a PDF AddWatermark task
$taskInfo = $client->createTask(CPDFDocumentEditor::ADD_WATERMARK);
// File handling parameter settings
$file = $client->addFile('test.pdf')
->setType('text')
->setScale('1')
->setOpacity('0.5')
->setRotation('0.785')
->setTargetPages('1-2')
->setVertalign('center')
->setHorizalign('left')
->setXOffset('100')
->setYOffset('100')
->setContent('text')
->setTextColor('#59c5bb')
->setFullScreen('1')
->setHorizontalSpace('10')
->setVerticalSpace('10');
// Upload files
$fileInfo = $file->uploadFile($taskInfo['taskId']);
// Execute task
$client->executeTask($taskInfo['taskId']);
// Query TaskInfo
$taskInfo = $client->getTaskInfo($taskInfo['taskId']);
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);
// Create a task
// Create an example of a PDF AddWatermark task
CPDFCreateTaskResult result = client.CreateTask(CPDFDocumentEditorEnum.ADD_WATERMARK);
// Get a task id
string taskId = result.TaskId;
// File handling parameter settings
CPDFAddWatermarkParameter fileParameter = new CPDFAddWatermarkParameter();
fileParameter.Type = "text";
fileParameter.Scale = "1";
fileParameter.Opacity = "0.5";
fileParameter.Rotation = "0.785";
fileParameter.TargetPages = "1-2";
fileParameter.Vertalign = "center";
fileParameter.Horizalign = "left";
fileParameter.Xoffset = "100";
fileParameter.Yoffset = "100";
fileParameter.Content = "test";
fileParameter.TextColor = "#59c5bb";
fileParameter.FullScreen = "1";
fileParameter.HorizontalSpace = "10";
fileParameter.VerticalSpace = "10";
// Upload files
client.UploadFile(new FileInfo("test.pdf"), taskId, fileParameter);
// Execute task
client.ExecuteTask(taskId);
// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.GetTaskInfo(taskId);
# Create a client
client = CPDFClient(public_key, secret_key)
# Create a task
# Create an example of a PDF AddWatermark task
create_task_result = client.create_task(CPDFDocumentEditorEnum.ADD_WATERMARK)
# taskId
task_id = create_task_result.task_id
# File handling parameter settings
file_parameter = CPDFAddWatermarkParameter()
file_parameter.type = "text"
file_parameter.scale = "1"
file_parameter.opacity = "0.5"
file_parameter.rotation = "0.785"
file_parameter.target_pages = "1-2"
file_parameter.vertalign = "center"
file_parameter.horizalign = "left"
file_parameter.xoffset = "100"
file_parameter.yoffset = "100"
file_parameter.content = "test"
file_parameter.text_color = "#59c5bb"
file_parameter.full_screen = "1"
file_parameter.horizontal_space = "10"
file_parameter.vertical_space = "10"
# upload File
upload_file_result = client.upload_file('test.pdf', task_id, file_parameter)
# Execute task
client.execute_task(task_id)
# get task processing information
task_info = client.get_task_info(task_id)
// Create a client
let client: CPDFClient = CPDFClient(publicKey: public_key, secretKey: secret_key)
Task { @MainActor in
// Create a task
// Create an example of a PDF AddWatermark task
let taskModel = await client.createTask(url: CPDFDocumentEditor.ADD_WATERMARK)
// Get a task id
let taskId = taskModel?.taskId ?? ""
// Upload file
let path = Bundle.main.path(forResource: "test", ofType: "pdf")
let uploadFileModel = await client.uploadFile(filepath: path ?? "", password: "", params: [
CPDFFileUploadParameterKey.textColor.string():"#59c5bb",
CPDFFileUploadParameterKey.type.string():"text",
CPDFFileUploadParameterKey.content.string():"text",
CPDFFileUploadParameterKey.scale.string():"1",
CPDFFileUploadParameterKey.opacity.string():"0.5",
CPDFFileUploadParameterKey.rotation.string():"0.785",
CPDFFileUploadParameterKey.targetPages.string():"1-2",
CPDFFileUploadParameterKey.vertalign.string():"center",
CPDFFileUploadParameterKey.horizalign.string():"left",
CPDFFileUploadParameterKey.xoffset.string():"100",
CPDFFileUploadParameterKey.yoffset.string():"100",
CPDFFileUploadParameterKey.fullScreen.string():"1",
CPDFFileUploadParameterKey.horizontalSpace.string():"10",
CPDFFileUploadParameterKey.verticalSpace.string():"10"
], taskId: taskId)
// Execute task
let _ = await client.processFiles(taskId: taskId)
// Query TaskInfo
let taskInfoModel = await client.getTaskInfo(taskId: taskId)
}
Code | Description |
---|---|
type | Watermark type (text: text type watermark, image: image type watermark). |
scale | Zoom (image type attribute). |
opacity | Transparency: 0~1. |
rotation | Rotation angle: A positive number means counterclockwise rotation. |
targetPages | Page number: Page number should be a positive integer greater than one. starts from 1, for example:1,2,4,6,9-11. |
vertalign | Vertical alignment (top、center、bottom). |
horizalign | Horizontal alignment (left, center, right). |
xoffset | Horizontal offset. |
yoffset | Vertical offset. |
content | Text. |
textColor | Text color, for example: #FFFFFF. |
front | Present on the front. |
fullScreen | Whether to fill the entire page. |
horizontalSpace | Horizontal spacing (supported only if — fullscreen exists) default value 50. |
verticalSpace | Vertical spacing (supported only if — fullscreen exists) default value 50. |
extension | Extended information, base64 encoding. |
Result:
File Type | Description |
---|---|
The PDF file after adding watermarks. |
Add Image Watermark
With the Add Watermark tool, you can add image watermarks to your PDFs. The following examples show how to upload a PDF file and run the Add Watermark feature using Java, PHP, C#, Python, and Swift programming languages. Then, output a PDF file.
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);
// Create a task
// Create an example of a PDF AddWatermark task
CPDFCreateTaskResult result = client.createTask(CPDFDocumentEditorEnum.ADD_WATERMARK);
// Get a task id
String taskId = result.getTaskId();
// File handling parameter settings
CPDFAddWatermarkParameter fileParameter = new CPDFAddWatermarkParameter();
fileParameter.setType("image");
fileParameter.setScale("0.5");
fileParameter.setOpacity("0.5");
fileParameter.setRotation("45");
fileParameter.setTargetPages("1-2");
fileParameter.setVertalign("center");
fileParameter.setHorizalign("left");
fileParameter.setXoffset("50");
fileParameter.setYoffset("50");
fileParameter.setFullScreen("1");
fileParameter.setHorizontalSpace("100");
fileParameter.setVerticalSpace("100");
fileParameter.setFront("1");
// Upload files
client.uploadFile(new File("test.pdf"), taskId, fileParameter,new File("sample/test.jpg"));
// Execute Task
client.executeTask(taskId);
// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.getTaskInfo(taskId);
// Create a client
$client = new CPDFClient('public_key', 'secret_key');
// Create a task
// Create an example of a PDF AddWatermark task
$taskInfo = $client->createTask(CPDFDocumentEditor::ADD_WATERMARK);
// File handling parameter settings
$file = $client->addFile('test.pdf')
->setType('image')
//Set Watermark Image
->setImagePath('test.jpg')
->setScale('0.5')
->setOpacity('0.5')
->setRotation('45')
->setTargetPages('1-2')
->setVertalign('center')
->setHorizalign('left')
->setXOffset('50')
->setYOffset('50')
->setFullScreen('1')
->setHorizontalSpace('100')
->setVerticalSpace('100')
->setFront('1');
// Upload files
$fileInfo = $file->uploadFile($taskInfo['taskId']);
// Execute task
$client->executeTask($taskInfo['taskId']);
// Query TaskInfo
$taskInfo = $client->getTaskInfo($taskInfo['taskId']);
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);
// Create a task
// Create an example of a PDF AddWatermark task
CPDFCreateTaskResult result = client.CreateTask(CPDFDocumentEditorEnum.ADD_WATERMARK);
// Get a task id
string taskId = result.TaskId;
// File handling parameter settings
CPDFAddWatermarkParameter fileParameter = new CPDFAddWatermarkParameter();
fileParameter.Type = "image";
fileParameter.Scale = "0.5";
fileParameter.Opacity = "0.5";
fileParameter.Rotation = "45";
fileParameter.TargetPages = "1-2";
fileParameter.Vertalign = "center";
fileParameter.Horizalign = "left";
fileParameter.Xoffset = "50";
fileParameter.Yoffset = "50";
fileParameter.FullScreen = "1";
fileParameter.HorizontalSpace = "100";
fileParameter.VerticalSpace = "100";
fileParameter.Front = "1";
// Upload files
client.UploadFile(new FileInfo("test.pdf"), taskId, fileParameter,new FileInfo("sample/test.jpg"));
// Execute task
client.ExecuteTask(taskId);
// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.GetTaskInfo(taskId);
# Create a client
client = CPDFClient(public_key, secret_key)
# Create a task
# Create an example of a PDF AddWatermark task
create_task_result = client.create_task(CPDFDocumentEditorEnum.ADD_WATERMARK)
# taskId
task_id = create_task_result.task_id
# File handling parameter settings
file_parameter = CPDFAddWatermarkParameter()
file_parameter.type = "image"
file_parameter.scale = "0.5"
file_parameter.opacity = "0.5"
file_parameter.rotation = "45"
file_parameter.target_pages = "1-2"
file_parameter.vertalign = "center"
file_parameter.horizalign = "left"
file_parameter.xoffset = "50"
file_parameter.yoffset = "50"
file_parameter.full_screen = "1"
file_parameter.horizontal_space = "100"
file_parameter.vertical_space = "100"
fileParameter.Front = "1";
# Upload file
upload_file_result = client.upload_file('test.pdf', task_id, file_parameter, image="sample/test.jpg")
# Execute task
client.execute_task(task_id)
# get task processing information
task_info = client.get_task_info(task_id)
// Create a client
let client: CPDFClient = CPDFClient(publicKey: public_key, secretKey: secret_key)
Task { @MainActor in
// Create a task
// Create an example of a PDF AddWatermark task
let taskModel = await client.createTask(url: CPDFDocumentEditor.ADD_WATERMARK)
// Get a task id
let taskId = taskModel?.taskId ?? ""
// Upload file
let path = Bundle.main.path(forResource: "test", ofType: "pdf")
let uploadFileModel = await client.uploadFile(filepath: path ?? "", password: "", params: [
CPDFFileUploadParameterKey.type.string():"image",
CPDFFileUploadParameterKey.filepath.string() : Bundle.main.path(forResource: "test", ofType: "jpg")!,
CPDFFileUploadParameterKey.scale.string():"0.5",
CPDFFileUploadParameterKey.opacity.string():"0.5",
CPDFFileUploadParameterKey.rotation.string():"45",
CPDFFileUploadParameterKey.targetPages.string():"1-2",
CPDFFileUploadParameterKey.vertalign.string():"center",
CPDFFileUploadParameterKey.horizalign.string():"left",
CPDFFileUploadParameterKey.xoffset.string():"50",
CPDFFileUploadParameterKey.yoffset.string():"50",
CPDFFileUploadParameterKey.fullScreen.string():"1",
CPDFFileUploadParameterKey.horizontalSpace.string():"100",
CPDFFileUploadParameterKey.verticalSpace.string():"100"
], taskId: taskId)
// Execute task
let _ = await client.processFiles(taskId: taskId)
// Query TaskInfo
let taskInfoModel = await client.getTaskInfo(taskId: taskId)
}
Code | Description |
---|---|
type | Watermark type (text: text type watermark, image: image type watermark). |
scale | Zoom (image type attribute). |
opacity | Transparency: 0~1. |
rotation | Rotation angle: A positive number means counterclockwise rotation. |
targetPages | Page number: Page number should be a positive integer greater than one. starts from 1, for example:1,2,4,6,9-11. |
vertalign | Vertical alignment (top, center, bottom). |
horizalign | Horizontal alignment (left, center, right). |
xoffset | Horizontal offset. |
yoffset | Vertical offset. |
content | Text. |
textColor | Text color, for example:#FFFFFF. |
front | Present on the front. |
fullScreen | Whether to fill the entire page. |
horizontalSpace | Horizontal spacing (supported only if --fullscreen exists) default value 50. |
verticalSpace | Vertical spacing (supported only if --fullscreen exists) default value 50. |
extension | Extended information, base64 encoding. |
Result:
File Type | Description |
---|---|
The PDF file after adding watermarks. |
Delete Watermark
With the Delete Watermark tool, you can delete the watermarks in your PDFs. The following examples show how to upload a PDF file and run the Delete Watermark feature using Java, PHP, C#, Python, and Swift programming languages. Then, output a PDF file.
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);
// Create a task
// Create an example of a PDF DeleteWatermark task
CPDFCreateTaskResult result = client.createTask(CPDFDocumentEditorEnum.DEL_WATERMARK);
// Get a task id
String taskId = result.getTaskId();
// File handling parameter settings
CPDFDeleteWatermarkParameter fileParameter = new CPDFDeleteWatermarkParameter();
// Upload files
client.uploadFile(new File("test.pdf"), taskId, fileParameter);
// Execute task
client.executeTask(taskId);
// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.getTaskInfo(taskId);
// Create a client
$client = new CPDFClient('public_key', 'secret_key');
// Create a task
// Create an example of a PDF DeleteWatermark task
$taskInfo = $client->createTask(CPDFDocumentEditor::DEL_WATERMARK);
// Upload files
$fileInfo = $client->addFile('test.pdf')->uploadFile($taskInfo['taskId']);
// Execute task
$client->executeTask($taskInfo['taskId']);
// Query TaskInfo
$taskInfo = $client->getTaskInfo($taskInfo['taskId']);
// Create a client
CPDFClient client = new CPDFClient(publicKey,secretKey);
// Create a task
// Create an example of a PDF DeleteWatermark task
CPDFCreateTaskResult result = client.CreateTask(CPDFDocumentEditorEnum.DEL_WATERMARK);
// Get a task id
string taskId = result.TaskId;
// File handling parameter settings
CPDFDeleteWatermarkParameter fileParameter = new CPDFDeleteWatermarkParameter();
// Upload files
client.UploadFile(new FileInfo("test.pdf"), taskId, fileParameter);
// Execute task
client.ExecuteTask(taskId);
// Query TaskInfo
CPDFTaskInfoResult taskInfo = client.GetTaskInfo(taskId);
# Create a client
client = CPDFClient(public_key, secret_key)
# Create a task
# Create an example of a PDF DeleteWatermark task
create_task_result = client.create_task(CPDFDocumentEditorEnum.DEL_WATERMARK)
# taskId
task_id = create_task_result.task_id
# File handling parameter settings
file_parameter = CPDFDeleteWatermarkParameter()
# Upload file
upload_file_result = client.upload_file('test.pdf', task_id, file_parameter)
# Execute task
client.execute_task(task_id)
# get task processing information
task_info = client.get_task_info(task_id)
// Create a client
let client: CPDFClient = CPDFClient(publicKey: public_key, secretKey: secret_key)
Task { @MainActor in
// Create a task
// Create an example of a PDF DeleteWatermark task
let taskModel = await client.createTask(url: CPDFDocumentEditor.DEL_WATERMARK)
// Get a task id
let taskId = taskModel?.taskId ?? ""
// Upload file
let path = Bundle.main.path(forResource: "test", ofType: "pdf")
let uploadFileModel = await client.uploadFile(filepath: path ?? "", password: "" ,params: [:], taskId: taskId)
// Execute task
let _ = await client.processFiles(taskId: taskId)
// Query TaskInfo
let taskInfoModel = await client.getTaskInfo(taskId: taskId)
}
Result:
File Type | Description |
---|---|
The PDF file after deleting watermarks. |