Show / Hide Table of Contents

Class PDFWatermarkJob

A job that applies a watermark to a PDF using the input and watermark assets.

Inheritance
System.Object
PDFServicesJob
PDFWatermarkJob
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
Type Name Description
IAsset asset

The IAsset object representing the output asset; cannot be null.

Returns
Type Description
PDFWatermarkJob

This PDFWatermarkJob instance.

Exceptions
Type Condition
System.ArgumentException

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
PDFWatermarkParams pdfWatermarkParams

PDFWatermarkParams object containing the PDFWatermark parameters; can not be null.

Returns
Type Description
PDFWatermarkJob

PDFWatermarkJob instance

In This Article
  • Constructors
    • PDFWatermarkJob(IAsset, IAsset)
  • Methods
    • SetOutput(IAsset)
    • SetParams(PDFWatermarkParams)
Back to top Copyright © 2020 Adobe. All rights reserved.