Welcome Guest Search | Active Topics | Sign In | Register

How to get transparent watermark using ASPXToPDF Options
Guna
Posted: Tuesday, July 16, 2013 1:24:06 AM
Rank: Newbie
Groups: Member

Joined: 7/16/2013
Posts: 1
Code: C#


My Source Page has the following tag

<eo:ASPXToPDF ID="ASPXToPDF1" runat="server" OnAfterRender="ASPXToPDF1_AfterRender" OnBeforeRender="ASPXToPDF1_BeforeRender"></eo:ASPXToPDF>




protected void Page_Load(object sender, EventArgs e)
{
.....
....
ASPXToPDF1.RenderAsPDF(filename);
}

protected void ASPXToPDF1_BeforeRender(object sender, EventArgs e)
{


}


protected void ASPXToPDF1_AfterRender(object sender, EventArgs e)
{

//Cast the Result property to HtmlToPdfResult
HtmlToPdfResult result = (HtmlToPdfResult)ASPXToPDF1.Result;

foreach (PdfPage page in doc.Pages)
{
int i;
float xPos = 200;
float yPos = 430;

EO.Pdf.Contents.PdfTextLayer textLayer = new EO.Pdf.Contents.PdfTextLayer();



textLayer.Font = new EO.Pdf.Drawing.PdfFont("Castellar", 35);
textLayer.NonStrokingColor = System.Drawing.Color.LightGray;


EO.Pdf.Contents.PdfTextContent textContent = new EO.Pdf.Contents.PdfTextContent(PDFReportConstants.WaterMarkText);
//textContent.PositionMode = EO.Pdf.Contents.PdfTextPositionMode.Offset;

//textContent.Offset = new EO.Pdf.Drawing.PdfPoint(xPos, yPos);
textLayer.GfxMatrix.Translate(xPos, yPos);
textLayer.GfxMatrix.Rotate(45);
//Add the text object into the text layer object
textLayer.Contents.Add(textContent);
//Add the text layer into the page
page.Contents.Add(textLayer);

}
}


Since am using AfterRender its adding the watermark text on the Generated PDF its not transparent . I referred the following link

http://www.essentialobjects.com/doc/4/web/aspxtopdf.aspx#debug

but i cant add the code in BeforeRender since the page will have no data.

The page Rendered Has too many textboxes,grids and charts so i am not comfortable using HtmlToPdf
,is there a way by which i can use the existing output ??

Like now i have the resulting pdf as 'OUTPUTPDF' .I can create another pdf with just watermark say WATERMARKPDF. Can we add the OUTPUTPDF content on WATERMARKPDF??

OR

is there any other way of doing the same using ASPXToPDF, Because we have got the license for EO PDF 2013

Thanks & Regards
Guna



eo_support
Posted: Tuesday, July 16, 2013 7:40:23 AM
Rank: Administration
Groups: Administration

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

You can use HtmlToPdf.Options.BeforeRenderPage. That can be set to a delegate and the delegate will be called on every PdfPage object before contents is generated on that page. You can then add the watermark inside that handler.

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.