Welcome Guest Search | Active Topics | Sign In | Register

Getting an error when rendering the pages numbers Options
Alester Gómez
Posted: Wednesday, August 22, 2012 11:19:14 PM
Rank: Member
Groups: Member

Joined: 7/10/2012
Posts: 14
Hi
I am trying to add the page number after making some operation, but I am getting an error. Here is my code:
.................

HtmlToPdfResult result = EO.Pdf.HtmlToPdf.ConvertUrl(path + "Layout.aspx", doc, options);
HtmlToPdfResult result_Portafolio = EO.Pdf.HtmlToPdf.ConvertUrl(path + "LayoutPotafoliot.aspx", doc_Portafolio, options);
HtmlToPdfResult result_UltimaParte = EO.Pdf.HtmlToPdf.ConvertUrl(path + "LayoutFinal.aspx", doc_UltimaParte, options);

//Colocando algunos valores de Portafolio
int z = 0;
int w = 0;
foreach (PdfPage page in doc_Portafolio.Pages)
{
HtmlElement e = result_Portafolio.HtmlDocument.GetElementById("lPortafolio_" + w.ToString());
string page_number = "";
PdfPageLocation location;

if (e != null)
{
location = e.Location;
page_number = location.Page.ToString().Replace("Page ", "");
int pnumber;
bool res = int.TryParse(page_number, out pnumber);
if (!res)
pnumber = 0;

if (pnumber == page.Index + 1)
{
AcmRender render = new AcmRender(page, 0, new AcmPageLayout(new AcmPadding(0)));

AcmTable table = new AcmTable(3f);
//table.Style.Border.Top = new AcmLineInfo(AcmLineStyle.Solid, Color.Black, 0.01f);
table.Style.Top = 0.70f;
table.Style.Left = 0.35f;
table.Style.ForegroundColor = Color.Black;

AcmTableRow tableRow;
AcmTableCell cell;

tableRow = new AcmTableRow();
if (z == 0)
cell = new AcmTableCell(new AcmText("Portfolio Detail"));
else
cell = new AcmTableCell(new AcmText(HttpUtility.HtmlDecode("  ")));
cell.Style.FontSize = 12f;
cell.Style.FontStyle = System.Drawing.FontStyle.Bold;

table.Rows.Add(tableRow);
tableRow.Cells.Add(cell);

tableRow = new AcmTableRow();
cell = new AcmTableCell(new AcmText(e.InnerText));
cell.Style.Border.Top = new AcmLineInfo(AcmLineStyle.Solid, Color.Black, 0.01f);
cell.Style.Border.Bottom = new AcmLineInfo(AcmLineStyle.Solid, Color.Black, 0.01f);
cell.Style.FontSize = 8f;

table.Rows.Add(tableRow);
tableRow.Cells.Add(cell);
render.Render(table, new AcmPageBreak());
w += 1;
}
}
z += 1;
}
PdfDocument doc_Final2 = new PdfDocument();
doc_Final2 = PdfDocument.Merge(doc, doc_Portafolio, doc_UltimaParte);


PdfDocument doc_Final3 = new PdfDocument();
doc_Final3 = doc_Final2.Clone();

foreach (PdfPage page in doc_Final3.Pages)
{
AcmRender render = new AcmRender(page, 0, new AcmPageLayout(new AcmPadding(0)));
AcmText text = new AcmText(String.Format("Page {0} of {1}", page.Index + 2, doc.Pages.Count + 1));

AcmBlock block = new AcmBlock(text);
block.Style.Top = 7.90F;
block.Style.Left = 10.75F;
block.Style.FontName = "Arial";
block.Style.FontSize = 8;
AcmBlock footer = new AcmBlock(block);
render.Render(block);
}

I am getting the error when the program exceute the red bold label:
"The object already has an owner. Please use a clone of the object instead."
eo_support
Posted: Thursday, August 23, 2012 7:45:56 AM
Rank: Administration
Groups: Administration

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

Please remove this line:

AcmBlock footer = new AcmBlock(block);

That line is not necessary.

Thanks!
Alester Gómez
Posted: Sunday, August 26, 2012 11:48:07 PM
Rank: Member
Groups: Member

Joined: 7/10/2012
Posts: 14
That work Perfectly!!!
Thanks a lot


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.