Last active
October 18, 2019 04:36
-
-
Save GroupDocsGists/50d5bd1274a6564091e4e1ee221526be to your computer and use it in GitHub Desktop.
GroupDocs.Watermark for .NET 19.10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (string filePath in Directory.GetFiles(@"C:\Documents")) | |
{ | |
using (Watermarker watermarker = new Watermarker(filePath)) | |
{ | |
TextWatermark watermark = new TextWatermark("top secret", new Font("Arial", 36)); | |
watermark.ForegroundColor = Color.Red; | |
watermark.HorizontalAlignment = HorizontalAlignment.Center; | |
watermark.VerticalAlignment = VerticalAlignment.Center; | |
watermarker.Add(watermark); | |
watermarker.Save(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (string filePath in Directory.GetFiles(@"C:\Documents")) | |
{ | |
using (Document document = Document.Load(filePath)) | |
{ | |
TextWatermark watermark = new TextWatermark("top secret", new Font("Arial", 36)) | |
watermark.ForegroundColor = Color.Red; | |
watermark.HorizontalAlignment = HorizontalAlignment.Center; | |
watermark.VerticalAlignment = VerticalAlignment.Center; | |
document.AddWatermark(watermark); | |
document.Save(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Watermarker watermarker = new Watermarker(@"C:\document.ppt")) | |
{ | |
IDocumentInfo info = watermarker.GetDocumentInfo(); | |
Console.WriteLine("File type: {0}", info.FileType); | |
Console.WriteLine("Number of pages: {0}", info.PageCount); | |
Console.WriteLine("Document size: {0} bytes", info.Size); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DocumentInfo documentInfo = Document.GetInfo(@"C:\document.ppt"); | |
Console.WriteLine(documentInfo.FileFormat); | |
Console.WriteLine(documentInfo.IsEncrypted); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Watermarker watermarker = new Watermarker(@"C:\document.pdf")) | |
{ | |
PossibleWatermarkCollection watermarks = watermarker.Search(); | |
watermarker.Remove(watermarks); | |
watermarker.Save(@"C:\document_without_watermarks.pdf"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Document doc = Document.Load(@"C:\document.pdf")) | |
{ | |
PossibleWatermarkCollection watermarks = doc.FindWatermarks(); | |
watermarks.Clear(); | |
doc.Save(@"C:\document_without_watermarks.pdf"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Watermarker watermarker = new Watermarker(@"C:\document.pdf")) | |
{ | |
SizeSearchCriteria widthRange = new SizeSearchCriteria(Dimension.Width, 50, 100); | |
RotateAngleSearchCriteria rotateAngle = new RotateAngleSearchCriteria(0, 45); | |
TextSearchCriteria textCriteria = new TextSearchCriteria(new Regex("^Test watermark$")); | |
PossibleWatermarkCollection watermarks = watermarker.Search(textCriteria.And(widthRange.Or(rotateAngle))); | |
Console.WriteLine("Found {0} possible watermarks.", watermarks.Count); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Document doc = Document.Load(@"C:\document.pdf")) | |
{ | |
SizeSearchCriteria widthRange = new SizeSearchCriteria(Dimension.Width, 50, 100); | |
RotateAngleSearchCriteria rotateAngle = new RotateAngleSearchCriteria(0, 45); | |
TextSearchCriteria textCriteria = new TextSearchCriteria(new Regex("^Test watermark$")); | |
PossibleWatermarkCollection watermarks = doc.FindWatermarks(textCriteria.And(widthRange.Or(rotateAngle))); | |
Console.WriteLine("Found {0} possible watermarks.", watermarks.Count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment