Doküman sisteme aktarılır, aspose word ile doküman tekrar oluşturulurken watermark eklenir. Dokümandaki görsellerde kaymalar olduğu görüntülenir. Orjinal doküman 20 sayfadır. Aspose word ile oluşan word dokümanı 23 sayfa oluşur.
Watermark kod bloğu
protected void SetWaterMarkWord(Aspose.Words.Document document)
{
Shape watermark = new Shape(document, ShapeType.TextPlainText);
watermark.Name = “WaterMark”;
// Set up the text of the watermark.
watermark.TextPath.Text = “Okuma Kopyasıdır”;
watermark.TextPath.Bold = true;
watermark.TextPath.Size = 30;
watermark.TextPath.FontFamily = “Arial”;
watermark.Width = 500;
watermark.Height = 100;
// Text will be directed from the bottom-left to the top-right corner.
watermark.Rotation = -45;
// Remove the following two lines if you need a solid black text.
watermark.Fill.Color = System.Drawing.Color.LightGreen; // Try LightGray to get more Word-style watermark
watermark.StrokeColor = System.Drawing.Color.LightGreen; // Try LightGray to get more Word-style watermark
// Place the watermark in the page center.
watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
watermark.WrapType = WrapType.None;
// Create a new paragraph and append the watermark to this paragraph.
Paragraph watermarkPara = new Paragraph(document);
watermarkPara.AppendChild(watermark);
foreach (Section sect in document.Sections)
{
// There could be up to three different headers in each section, since we want
// The watermark to appear on all pages, insert into all headers.
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary);
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst);
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven);
}
// document.Save(uplFile.FileName + "_WaterMark", uzanti.ToLower() == ".doc" ? Aspose.Words.SaveFormat.Doc : Aspose.Words.SaveFormat.Docx);
}
private static void InsertWatermarkIntoHeader(Paragraph watermarkPara, Section sect, HeaderFooterType headerType)
{
HeaderFooter header = sect.HeadersFooters[headerType];
if (header == null)
{
// There is no header of the specified type in the current section, create it.
header = new HeaderFooter(sect.Document, headerType);
sect.HeadersFooters.Add(header);
}
// Insert a clone of the watermark into the header.
header.AppendChild(watermarkPara.Clone(true));
}
I attached the original file and corrupted file. We are using Aspose.Word.20.12 version. Thanks
YG13691.zip (2.7 MB)