Welcome Guest Search | Active Topics | Sign In | Register

Total page number in content Options
Rahesh
Posted: Monday, July 23, 2012 7:54:09 AM
Rank: Newbie
Groups: Member

Joined: 6/7/2012
Posts: 6
How to display total page number in page content not in header and footer.

Thanks
eo_support
Posted: Monday, July 23, 2012 9:30:30 AM
Rank: Administration
Groups: Administration

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

You can use PdfDocument.Pages.Count to get the total page number, then either use ConvertHtml or PDF Creator (ACM) interface to output the page number anywhere you want.

Thanks!
Rahesh
Posted: Wednesday, July 25, 2012 12:14:20 AM
Rank: Newbie
Groups: Member

Joined: 6/7/2012
Posts: 6
Hi,
I used the code as shown below. I got the total page count always be empty.


Print button click

protected void BtnPrintPriview_Click(object sender, EventArgs e)
{

Button BtnPrint = (Button)((Control)(sender));
Session["url"] = "OrderPrint.aspx?OrderRef=" + TxtOrderRef.Text + "&TotalPages=" + TxtPTotalPages.Text + "&SupplierName=" + BtnPrint.CommandName + "&ItemIndex=" + BtnPrint.CommandArgument;
ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('../PrintAsPdfForOrder.aspx','PrintMe','height=600px,width=600px,scrollbars=1');</script>");

}


PrintAsPdfForOrder page


public partial class PrintAsPdfForOrder : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{

Runtime.AddLicense(licence key);
PdfDocument doc = new PdfDocument();
HtmlToPdf.Options.FooterHtmlFormat = "Page {page_number}";
HtmlToPdf.Options.AfterRenderPage = new PdfPageEventHandler(On_AfterRenderPage);
string url = Request.Url.ToString();
string[] str = url.Split('?');
url = str[0].Replace("PrintAsPdfForOrder.aspx", Convert.ToString(Session["Url"]));
if (url.Contains("?"))
{
url = url + "&Pages=" + doc.Pages.Count.ToString();//Attach the page count with url
}
else
{
url = url + "?Pages=" + doc.Pages.Count.ToString();
}
HtmlToPdf.ConvertUrl(url, doc);

//url is the url to a page that I want to print .Retrieve page count from url and bind in print page

HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearHeaders();
response.ContentType = "application/pdf";
doc.Save(response.OutputStream);

}

}


private void On_AfterRenderPage( object sender, EO.Pdf.PdfPageEventArgs e)
{

EO.Pdf.HtmlToPdf.Options.OutputArea = new RectangleF(0.1f, 0.1f, 8.3f, 12f);
EO.Pdf.HtmlToPdf.ConvertHtml(@"<div style='width:300px;height:74px;margin:auto;'><img src='http://www.medarabco.com/images/med-logo.jpg' width='300' height='74' ></div></div>",
e.Page);

}
}
eo_support
Posted: Wednesday, July 25, 2012 7:39:49 AM
Rank: Administration
Groups: Administration

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

We won't review or debug your code. You have to explain why you think your code should work first.

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.