Welcome Guest Search | Active Topics | Sign In | Register

Additional Watermark questions... Options
Scott
Posted: Monday, October 5, 2015 1:57:38 PM
Rank: Newbie
Groups: Member

Joined: 10/1/2015
Posts: 3
Hello, I am trying to add a watermark to the blank section of my document, not the entire page. So I need to generate the .pdf first to determine if I have white space first. This is my code:

HtmlToPdfResult convertResult = EO.Pdf.HtmlToPdf.ConvertHtml(printOutHtml, doc);

// add watermark if enough blank space on last page
if (convertResult.LastPosition > 2)
{
PdfPage page = doc.Pages[convertResult.LastPageIndex];

HtmlToPdf.ConvertHtml("DO NOT WRITE IN THIS SPACE!", page);
}

This puts "DO NOT WRITE IN THIS SPACE!" at the top of the page. What I want is the diagonal traditional watermark in my blank space. I found an example on your website but it renders it before the content is created. I do like the layout of the watermark though. Is there some way to salvage this code without having to create an event? I guess I'm just trying to add the textLayer object back onto my existing .pdf page.

private void BeforeRenderPage(object sender, AcmPageEventArgs e)
{
//Create a new text layer
EO.Pdf.Contents.PdfTextLayer textLayer = new EO.Pdf.Contents.PdfTextLayer();

//Use a big font, light text color and also
//rotate the text 45 degrees
textLayer.Font = new EO.Pdf.Drawing.PdfFont("Arial", 50);
textLayer.NonStrokingColor = Color.LightGray;
textLayer.GfxMatrix.Rotate(45);

//Create the text object
EO.Pdf.Contents.PdfTextContent textContent = new EO.Pdf.Contents.PdfTextContent("CONFIDENTIAL");
textContent.PositionMode = EO.Pdf.Contents.PdfTextPositionMode.Offset;
textContent.Offset = new EO.Pdf.Drawing.PdfPoint(350, 150);

//Add the text object into the text layer object
textLayer.Contents.Add(textContent);

//Add the text layer into the page
e.Page.Contents.Add(textLayer);
}
eo_support
Posted: Monday, October 5, 2015 3:30:04 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

You do not need an event if you wish to do it after. You just call the same code after you call ConvertHtml except for replacing e.Page in the code with your page variable (from "page = doc.Pages[convertResult.LastPageIndex]").

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.