This gist explains the steps and code snippet for the addition of Text and Image watermarks to PDF files using Aspose.PDF Cloud SDK for Python.
For more information, please visit
This gist explains the steps and code snippet for the addition of Text and Image watermarks to PDF files using Aspose.PDF Cloud SDK for Python.
For more information, please visit
# For more examples, please visit https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-python | |
def textWatermark(): | |
try: | |
#Client credentials | |
client_secret = "406b404b2df649611e508bbcfcd2a77f" | |
client_id = "88d1cda8-b12c-4a80-b1ad-c85ac483c5c5" | |
#initialize PdfApi client instance using client credetials | |
pdf_api_client = asposepdfcloud.api_client.ApiClient(client_secret, client_id) | |
# create PdfApi instance while passing PdfApiClient as argument | |
pdf_api = PdfApi(pdf_api_client) | |
#input PDF file name | |
input_file = 'awesomeTable.pdf' | |
# page number of PDF where text stamp needs to be added | |
pageNumber = 1 | |
textStamp = asposepdfcloud.models.Stamp | |
textStamp.type = 'Text' | |
textStamp.background = True | |
textStamp.horizontal_alignment = 1 #Left | |
textStamp.opacity = 0.5 | |
textStamp.rotate = 1 | |
textStamp.rotate_angle = 45 | |
textStamp.x_indent=100 | |
textStamp.y_indent=100 | |
textStamp.zoom=1.5 | |
textStamp.value = 'Confidential' | |
textState = asposepdfcloud.TextState | |
textState.font_size = 20 | |
textState.font= 'Arial' | |
textState.foreground_color = {'A': 0, | |
'R': 200, | |
'G': 0, | |
'B': 0 } | |
textState.background_color = { | |
'A': 10, | |
'R': 0, | |
'G': 0, | |
'B': 0} | |
textState.font_style = 2 | |
textStamp.vertical_alignment = 1 | |
#invoke Aspose.Pdf Cloud SDK API to insert text watermark in PDF file | |
response = pdf_api.post_page_text_stamps(input_file, pageNumber, textStamp) | |
# print message in console (optional) | |
print('Text Watermark successfully added to PDF document !') | |
except ApiException as e: | |
print("Exception while calling PdfApi: {0}".format(e)) | |
print("Code:" + str(e.code)) | |
print("Message:" + e.message) |
This Gist contains code snippets regarding the addition of Text and Image watermarks to PDF files using Aspose.PDF Cloud SDK for Python |