title: How to add watermark to aspose pdf and word that contain table
body: <p>I generate a <code>Aspose.Generate.Pdf</code> file and then add a <code>Aspose.Pdf.Generator.Table</code>to it by following method. but when I add watermark to this pdf file, it covers by created table:</p>
  
  <pre><code>   public static BasketResult&lt;string&gt; ExportDataTableToPdf(DataTable inputDataTable, string CaptionFilename)
      {
          List&lt;DataColumn&gt; listDataColumns = GetDataColumns(inputDataTable, CaptionFilename);
          BasketResult&lt;string&gt; returnResult = new BasketResult&lt;string&gt;();
          String rtnPathFile = String.Empty;
          int rowCount = inputDataTable.Rows.Count;
  
          if (rowCount &lt;= 1000)
          {
              try
              {
                  string dataDir = Settings.TempPath;
  
                  if (!Directory.Exists(dataDir))
                      Directory.CreateDirectory(dataDir);
  
                  Pdf pdfConv = new Pdf();
                  pdfConv.IsRightToLeft = true;
                  Aspose.Pdf.Generator.Section mainSection = pdfConv.Sections.Add();
                  mainSection.TextInfo.IsRightToLeft = true;
                  mainSection.IsLandscape = true;
                  mainSection.TextInfo.Alignment = AlignmentType.Right;
  
                  // header definition begin
                  Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(mainSection);
                  mainSection.EvenHeader = header;
                  mainSection.OddHeader = header;
                  header.Margin.Top = 50;
                  Aspose.Pdf.Generator.Table headerTable = new Aspose.Pdf.Generator.Table();
                  header.Paragraphs.Add(headerTable);
                  headerTable.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);
                  headerTable.Alignment = AlignmentType.Right;
                  headerTable.DefaultColumnWidth = "80";
                  headerTable.FixedHeight = 30;
                  Aspose.Pdf.Generator.Row headerRow = headerTable.Rows.Add();
                  headerRow.BackgroundColor = new Aspose.Pdf.Generator.Color("#D3DFEE");
  
                  int index = 0;
                  listDataColumns.Reverse();
  
                  foreach (DataColumn column in listDataColumns)
                  {
                      string cellText = column.Caption;
                      headerRow.Cells.Add(cellText);
                      headerRow.Cells[index].DefaultCellTextInfo.FontName = "Tahoma";
                      headerRow.Cells[index].DefaultCellTextInfo.IsRightToLeft = true;
                      headerRow.Cells[index].VerticalAlignment = VerticalAlignmentType.Center;
                      headerRow.Cells[index++].Alignment = AlignmentType.Center;
                  }
  
                  Document doc = new Document();
                  DocumentBuilder builder = new DocumentBuilder(doc);
                  Aspose.Words.Tables.Table wordTable = ImportTableFromDataTable(builder, inputDataTable,
                      CaptionFilename, true);
  
                  string columnWidths = "";
                  for (int j = 0; j &lt; wordTable.FirstRow.Count; j++)
                  {
                      columnWidths = columnWidths + "80 ";
                  }
  
                  Aspose.Pdf.Generator.Table table = new Aspose.Pdf.Generator.Table();
                  mainSection.Paragraphs.Add(table);
                  table.ColumnWidths = columnWidths;
                  table.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);
                  table.Alignment = AlignmentType.Right;
  
                  //fill table
                  for (int i = 1; i &lt; wordTable.Rows.Count; i++)
                  {
                      Aspose.Pdf.Generator.Row row = table.Rows.Add();
                      row.BackgroundColor = i % 2 == 0
                          ? new Aspose.Pdf.Generator.Color("#D3DFEE")
                          : new Aspose.Pdf.Generator.Color("#FFFFFF");
                      var wordTableRow = wordTable.Rows[i];
                      //fill columns from end to begin because table is left to right
                      for (int c = wordTable.FirstRow.Count - 1; c &gt;= 0; c--)
                      {
                          var cellValue = wordTableRow.ChildNodes[c];
                          string cellText = cellValue.GetText();
                          row.Cells.Add(cellText);
                      }
  
                      //set style to every cell
                      for (int c = 0; c &lt; wordTable.FirstRow.Count; c++)
                      {
                          row.Cells[c].DefaultCellTextInfo.FontName = "Tahoma";
                          row.Cells[c].DefaultCellTextInfo.IsRightToLeft = true;
                          row.Cells[c].VerticalAlignment = VerticalAlignmentType.Center;
                          row.Cells[c].Alignment = AlignmentType.Center;
                      }
                  }
  
                  pdfConv.SetUnicode();
  
                  rtnPathFile = Helper.GetTempFile() + ".pdf";
                  string fileName = Helper.GetFileNameFromFilePath(rtnPathFile);
                  pdfConv = AddPdfWatermark(pdfConv);
                  pdfConv.Save(dataDir + fileName);
                  returnResult.Result.Add(rtnPathFile);
                  returnResult.IsSuccess = true;
  
              }
              catch (Exception ex)
              {
                  rtnPathFile = String.Empty;
                  returnResult.IsSuccess = false;
                  returnResult.Result.Add(rtnPathFile);
                  returnResult.persianErrorMessages.Add(Messages.Err_InvalidFilePath);
              }
          }
          else
          {
              returnResult.IsSuccess = false;
              returnResult.Result.Add(rtnPathFile);
              returnResult.persianErrorMessages.Add(Messages.Err_CreateFile);
          }
  
          return returnResult;
      }
  </code></pre>
  
  <p>and AddPdfWatermerk method is :</p>
  
  <pre><code>   private static Pdf AddPdfWatermark(Aspose.Pdf.Generator.Pdf pdfConv)
      {
          try
          {
              // Create FloatingBox with x as width and y as height
              Aspose.Pdf.Generator.FloatingBox background = new Aspose.Pdf.Generator.FloatingBox(); // width, height
              Aspose.Pdf.Generator.Image backImage = new Aspose.Pdf.Generator.Image();
  
              string path = HttpContext.Current.Server.MapPath("~/images/PrivateExcelBackGround.png");
              byte[] bgBuffer = File.ReadAllBytes(path);
              MemoryStream streamBack = new MemoryStream(bgBuffer, false);
  
              backImage.ImageInfo.ImageStream = streamBack;
              background.Paragraphs.Add(backImage);
              background.ZIndex = 1000;
              pdfConv.Watermarks.Add(background);
  
              pdfConv.IsWatermarkOnTop = false;
              return pdfConv;
          }
          catch
          {
              return pdfConv;
          }
      }
  </code></pre>
  
  <p>I tried stamp instead of watermark, but table masks it too.
  in aspose.words.document file I have a problem too, in word file with mentioned table,watermark added correctly  but when a colored alternate table rows, watermark covered by colorful rows. </p>