forked from VahidN/iTextSharp.LGPLv2.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue39.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.IO; | ||
using iTextSharp.text; | ||
using iTextSharp.text.pdf; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace iTextSharp.LGPLv2.Core.FunctionalTests.Issues | ||
{ | ||
/// <summary> | ||
/// https://github.com/VahidN/iTextSharp.LGPLv2.Core/issues/39 | ||
/// </summary> | ||
[TestClass] | ||
public class Issue39 | ||
{ | ||
[TestMethod] | ||
public void Verify_Issue39_CanBe_Processed() | ||
{ | ||
var pdfFile = TestUtils.GetPdfsPath("issue39.pdf"); | ||
var pdfReader = new PdfReader(pdfFile); | ||
|
||
var pdfFilePath = TestUtils.GetOutputFileName(); | ||
var outStream = new FileStream(pdfFilePath, FileMode.Create); | ||
|
||
var pdfStamper = new PdfStamper(pdfReader, outStream); | ||
int total = pdfReader.NumberOfPages + 1; | ||
var pageSize = pdfReader.GetPageSize(1); | ||
var width = pageSize.Width; | ||
var height = pageSize.Height; | ||
|
||
//var font = TestUtils.GetUnicodeFont("Tahoma", TestUtils.GetTahomaFontPath(), 10, Font.BOLD, BaseColor.Black); | ||
//var font = TestUtils.GetUnicodeFont("FangSong", TestUtils.GetFontPath("simfang.ttf"), 10, Font.BOLD, BaseColor.Black); | ||
var font = BaseFont.CreateFont(TestUtils.GetFontPath("simfang.ttf"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); | ||
PdfGState gs = new PdfGState(); | ||
for (int i = 1; i < total; i++) | ||
{ | ||
var content = pdfStamper.GetOverContent(i); | ||
gs.FillOpacity = 0.3f; | ||
content.SetGState(gs); | ||
content.BeginText(); | ||
content.SetColorFill(BaseColor.LightGray); | ||
content.SetFontAndSize(font, 100); | ||
content.SetTextMatrix(0, 0); | ||
content.ShowTextAligned( | ||
Element.ALIGN_CENTER, | ||
"WaterMark Name ...", | ||
(width / 2) - 50, | ||
(height / 2) - 50, | ||
55); | ||
content.EndText(); | ||
} | ||
|
||
pdfStamper.Close(); | ||
pdfReader.Close(); | ||
outStream.Dispose(); | ||
} | ||
} | ||
} |
Binary file added
BIN
+10.1 MB
src/iTextSharp.LGPLv2.Core.FunctionalTests/iTextExamples/resources/fonts/simfang.ttf
Binary file not shown.
Binary file added
BIN
+833 KB
src/iTextSharp.LGPLv2.Core.FunctionalTests/iTextExamples/resources/pdfs/issue39.pdf
Binary file not shown.