Aspose Watermark Issue / Collapse or split in one or two pages

Hello Aspose Support, I tried to used your example of setting up Aspose Watermarks but this split the Text(“Draft” word in this case) into two page causing a collapse of the page.

Here is the code I used:

public static void GetDocumentDraft(string language)
{
    var license = new Aspose.Words.License();
    license.SetLicense(AppSettingKey.asposeLicense);
    if (language != "en")
    {
        Document doc = new Document(@"C:\Documents\document.docx");
        TextWatermarkOptions options = new TextWatermarkOptions()
        {
            FontFamily = "Courier New Bold",
            FontSize = 30, // reduce font size to 20
            Color = Color.Black,
            Layout = WatermarkLayout.Diagonal,
            IsSemitrasparent = true
        };

        doc.Watermark.SetText("DRAFT", options);
        // Save the result.
        doc.Save(@"C:\Documents\document.pdf");
    }
}

I upload some examples of the issue using the Set.text (“Draft”) and without it :
TEST.docx (20.7 KB)
DocumentTestDraft.pdf (45.3 KB)
DocumentWithoutWaterMark.pdf (39.6 KB)

Its should be in one page but for some reason when I add the Draft word is collapse and split in two pages, I already tried to lower the Font Size

@iolivari1 when you add a watermark a header is added to your document, (you can easily check that saving the document in docx format). By default an area at the top and the bottom of the document is reserved for headers and footers, but your original document don’t have that space, what is affecting your document is the addition of a header, you can fix that setting the HeaderDistance and the TopMargin to zero:

Document doc = new Document(@"C:\Temp\input.docx");
Document clon = (Document)doc.Clone(true);
TextWatermarkOptions options = new TextWatermarkOptions()
{
    FontFamily = "Courier New Bold",
    FontSize = 30, // reduce font size to 20
    Color = Color.Black,
    Layout = WatermarkLayout.Diagonal,
    IsSemitrasparent = true,
};

clon.Watermark.SetText("DRAFT", options);
clon.FirstSection.PageSetup.HeaderDistance = 0;
clon.FirstSection.PageSetup.TopMargin = 0;
// Save the result.

clon.Save(@"C:\Temp\output.pdf");
1 Like

It worked, thanks!

2 Likes