Watermark is Shrinking on big Pdfs (Poster size)
I wonder if there is an absolute and relative approach to the waterwark size on a document
see below for more details......
CASE #
PDFKITNET-5763
Hi,
I am using the following code. I used font size as 40 to display the watermark. but for some document the watermark is diplayed with the proper font size. for certain pdf document the font size is getting shrunk. for some other file it is saying that font is not available. so it is displaying watermark as dots. for all the documents same code and machine is used to display the watermark.
Shrink Watermark Display doc: ShrinkWatermark.pdf ( Look in the left bottom of doc to see the watermark. see the text NBCUConfidential. This text is displayed as watermark)
Original Shrink Watermark Display doc: OriginalShrinkWatermark.pdf(Use this doc to reproduce the issue)
Font Not Supporting doc: Fontnotsupporting.pdf (Here watermark is displyed as dots since font is not supported. In the same machine for other docs water mark is coming. only for this doc it is coming as dots)
Original Font Not Supporting Doc: OriginalFontNotSupporting.pdf (Use this doc to reproduce the same)
Proper Watermark Display Doc: Properwatermarkdisplay.pdf (For this document watermark is displayed properly)
Original Proper watermark display doc: orginalproperwatermarkdisplay.pdf (Use this doc for testing)
Note: All the docs are used in the same machine using the below code. In the same machine and for same code, it is giving different result. I think there should be some document dependency.
Kindly go through these issues and give me solution as early as possible.
aFS = New FileStream(strfilename, FileMode.Open, FileAccess.Read)
aMS1 = New MemoryStream
Dim aPFS As PdfFileStamp = New PdfFileStamp(aFS, aMS1)
' Add Footer
Dim aFT As FormattedText = New FormattedText(DateTime.Now.ToString(), System.Drawing.Color.FromArgb(0, 0, 255), "Arial", EncodingType.Winansi, False, 12)
aPFS.AddFooter(aFT, 20)
'Instantiate a stamp object
Dim strWatermark As String = ConfigurationSettings.AppSettings("WaterMarkText")
Dim logoStamp As Stamp = New Stamp
logoStamp.Opacity = 0.5F
Dim formatText As FormattedText = New FormattedText(strWatermark, System.Drawing.Color.FromArgb(192, 192, 192), "Arial", EncodingType.Winansi, False, 40)
formatText.AddNewLineText(strUsername)
'BindLogo to PDF
logoStamp.BindLogo(formatText)
logoStamp.IsBackground = False
logoStamp.Rotation = 50
logoStamp.SetOrigin(100, 150)
aPFS.AddStamp(logoStamp)
aPFS.Close()
Dim aPdfFI As New PdfFileInfo(strfilename)
Dim aMS2 As MemoryStream = New MemoryStream
Dim aPFS1 As PdfFileStamp = New PdfFileStamp(aMS1, aMS2)
Dim formatPageNoText As FormattedText = New FormattedText("Page #" + " of " + aPdfFI.NumberofPages.ToString(), System.Drawing.Color.FromArgb(0, 0, 255), "Arial", EncodingType.Winansi, False, 10)
aPFS1.AddPageNumber(formatPageNoText, 1)
aPFS1.Close()
a = aMS2.ToArray()
Response.Clear()
Response.AddHeader("Content-Length", a.Length.ToString())
Response.AppendHeader("Content-disposition", "filename=" + filename)
Response.ContentType = "application/pdf"
Response.AddHeader("Expires", "0")
Response.AddHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0")
Response.AddHeader("Pragma", "public")
Response.BinaryWrite(a)
Response.Flush()
aFS.Flush()
aFS.Close()
aMS1.Flush()
aMS1.Close()
aMS2.Close()
aMS2.Close()
Response.End()
Thank You
Regards
Srirangam K