Class PDFWatermarkJob
A job that applies a watermark to a PDF using the input and watermark assets.
Namespace: Adobe.PDFServicesSDK.pdfjobs.jobs
Assembly: Adobe.PDFServicesSDK.Doc.dll
Syntax
public class PDFWatermarkJob : PDFServicesJob
Examples
Sample Usage:
using Stream inputStream = File.OpenRead("<SOURCE_PATH>");
ICredentials credentials = new ServicePrincipalCredentials(
Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_ID"),
Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_SECRET"));
PDFServices pdfServices = new PDFServices(credentials);
Stream sourceFileInputStream = File.OpenRead(@"pdfWatermarkInput.pdf");
IAsset inputDocumentAsset = pdfServices.Upload(sourceFileInputStream, PDFServicesMediaType.PDF.GetMIMETypeValue());
Stream watermarkFileInputStream = File.OpenRead(@"watermark.pdf");
IAsset watermarkDocumentAsset = pdfServices.Upload(watermarkFileInputStream, PDFServicesMediaType.PDF.GetMIMETypeValue());
PageRanges pageRangeForPDFWatermark = new PageRanges();
pageRangeForPDFWatermark.AddSinglePage(1);
pageRangeForPDFWatermark.AddRange(3, 4);
WatermarkAppearance watermarkAppearance = new WatermarkAppearance();
watermarkAppearance.SetOpacity(50);
PDFWatermarkParams pdfWatermarkParams = PDFWatermarkParams.PDFWatermarkParamsBuilder()
.WithPageRanges(pageRangesForPDFWatermark)
.WithWatermarkAppearance(watermarkAppearance).Build();
PDFWatermarkJob pdfWatermarkJob = new PDFWatermarkJob(inputDocumentAsset, watermarkDocumentAsset).SetParams(pdfWatermarkParams);
String location = pdfServices.Submit(pdfWatermarkJob);
PDFServicesRespone<PDFWatermarkResult> pdfServicesResponse =
pdfServices.GetJobResult<PDFWatermarkResult>(location, typeof(PDFWatermarkResult));
IAsset resultAsset = pdfServicesResponse.Result.Asset;
StreamAsset streamAsset = pdfServices.GetContent(resultAsset);
Constructors
PDFWatermarkJob(IAsset, IAsset)
Constructs a new PDFWatermarkJob
instance.
Declaration
public PDFWatermarkJob(IAsset inputDocumentAsset, IAsset watermarkDocumentAsset)
Parameters
Type | Name | Description |
---|---|---|
IAsset | inputDocumentAsset | The input IAsset for the job; cannot be null. |
IAsset | watermarkDocumentAsset | The input IAsset object containing the watermark file; can not be null |
Methods
SetOutput(IAsset)
Sets the output asset for the job.
Declaration
public PDFWatermarkJob SetOutput(IAsset asset)
Parameters
Returns
Type | Description |
---|---|
PDFWatermark |
This |
Exceptions
Type | Condition |
---|---|
System. |
Thrown if the input asset is a CloudAsset and trying to set an output asset. |
SetParams(PDFWatermarkParams)
Set params for the job.
Declaration
public PDFWatermarkJob SetParams(PDFWatermarkParams pdfWatermarkParams)
Parameters
Type | Name | Description |
---|---|---|
PDFWatermark |
pdfWatermarkParams | PDFWatermark |
Returns
Type | Description |
---|---|
PDFWatermark |
|