Welcome Guest Search | Active Topics | Sign In | Register

problem using AcmBlock and HtmlToPdf together Options
master83
Posted: Tuesday, March 6, 2012 2:31:44 PM
Rank: Member
Groups: Member

Joined: 3/6/2012
Posts: 19
Hii. I am using PDF Converter. problem in my application i am facing is..

i am using some AcmBlock control then after that i am using HtmlToPdf Converter in between.. after HtmlToPdf Converter i am using AcmBlock control again..

Problem i am facing is i am unable to keep location of HtmlToPdf object. i mean.. until i use AcmBlock it works fine.. but after AcmBlock when i use HtmlToPdf object.. my last position to render another AcmBlock gets lost.

I can use HtmlToPdfResult object, but that doesn't work as it should. Can you refer any other solution to this problem where i can use AcmBlock then HtmlToPdf Converter all together without losing my last position to render another AcmBlock or HtmlToPdf. Also there can be multiple pages depending upon the data i have to convert into pdf.

Thanks in advance for support.

Rahul
eo_support
Posted: Tuesday, March 6, 2012 2:39:44 PM
Rank: Administration
Groups: Administration

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

You should be able to use them both together without any problem. If you run into problems, you can try to isolate the problem into a small peice of test code that demonstrates the problem, as soon as we have that we will be happy to look into it for you.

Also if you use HTML to PDF and needs position information from the conversion, you need to use HtmlToPdfResult. We are not aware of any problem with HtmlToPdfResult. Once again, if you run into problems with that, please provide test code and we will be look into it.

Thanks!
master83
Posted: Tuesday, March 6, 2012 3:39:09 PM
Rank: Member
Groups: Member

Joined: 3/6/2012
Posts: 19

Thanks for the quick response!

here is my small snippet of code

after rendering some AcmBlock controls on my pdf.. here is what i do to render Html

PdfDestination pdfDestination = acmAch.CreateDestination();
HtmlToPdf.Options.StartPageIndex = doc.Pages[doc.Pages.Count - 1].Index;
HtmlToPdf.Options.StartPosition = ((10*72 - pdfDestination.FitRect.Y1) / 72) + 0.8f;
HtmlToPdf.Options.ZoomLevel = 0.68f;
HtmlToPdf.Options.PageSize = PdfPageSizes.A4;
HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None;
HtmlToPdf.Options.OutputArea = new RectangleF(0.43f, 1f, PdfPageSizes.A4.Width - 1f, PdfPageSizes.A4.Height - 1.5f);

htmlToPdfResult = HtmlToPdf.ConvertHtml(strInfo.ToString(), doc);

it renders fine... but after this when i render AcmBlock.. i am unable to get the last position to render from

i have tried LastPosition from htmlToPdfResult but that doesn't give me the correct location. Also my html could shift to next page since my text is quite big. i also have to render html again after my next AcmBlock which is again tough since i dont know the last location where i should start my html to render from. if you can tell me some properties of htmlToPdfResult or link to an article, that would be great.

Thanks!
eo_support
Posted: Tuesday, March 6, 2012 3:48:51 PM
Rank: Administration
Groups: Administration

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

You will have to produce a complete sample to demonstrate what you are trying to do and tell us exactly which line of code is not working correctly. For example, you can say, run this code, you will see on line 10 variable A has an value of X, in fact it should be value Y. We will then take the same code, run it here and if we see the same result but the result actually makes sense and is correct, then we will try to explain to you why it is correct; or if it is wrong, then we will find out what's wrong for you. The basic principle here is we do not do "can you try this", "maybe we need to change that" kind of guess work. Basically you show us the problem and we will track it down for you and give you a definite answer for that problem.

Thanks!
master83
Posted: Tuesday, March 6, 2012 5:14:30 PM
Rank: Member
Groups: Member

Joined: 3/6/2012
Posts: 19
here is my small code.. hope will help

AcmContent otherContent= new AcmContent();
AcmRender renderer = new AcmRender(doc, pageLayout);
renderer.SetDefPageSize(new SizeF(PdfPageSizes.A4.Width, PdfPageSizes.A4.Height));
renderer.BeforeRenderPage += renderer_AfterRenderPage;

//Empty block
AcmBlock emptyBlock = new AcmBlock();
otherContent.Children.Add(emptyBlock);
renderer.Render(otherContent);

PdfDestination pdfDestination = emptyBlock.CreateDestination();
HtmlToPdf.Options.StartPageIndex = pdfDestination.Page.Index;
HtmlToPdf.Options.StartPosition =(float)(10 * 72 - pdfDestination.FitRect.Y1) / 72;
HtmlToPdf.Options.ZoomLevel = 0.68f;
HtmlToPdf.Options.OutputArea = new RectangleF(0.43f, 1.1f, doc.Pages[0].Size.Width - 1f, doc.Pages[0].Size.Height -1.5f);
htmlToPdfResult = HtmlToPdf.ConvertHtml("<ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol><ol><li>Topper</li><li>Toper in Graduation<b>BCA</b></li></ol>", doc);

I have a footer on my page.. problem is when i render this html it overlaps my footer and rest of the text comes on the next page. how can stop this text not to overlap my footer rather stop just before my footer and render rest of the text on next page. so that i can render my other AcmBlock after that. Here is the code for my footer.

void renderer_AfterRenderPage(object sender, AcmPageEventArgs e)
{
PdfPage page = e.Page;
AcmRender render = new AcmRender(page, 0, new AcmPageLayout(new AcmPadding(0.4f, 0, 0.4f, 0)));
render.SetDefPageSize(new SizeF(PdfPageSizes.A4.Width, PdfPageSizes.A4.Height));
AcmBlock footer = new AcmBlock(new AcmText("Footer Text"));
footer.Style.Border.Top = new AcmLineInfo(AcmLineStyle.Solid, Color.LightGray, 0.01f);
footer.Style.Top = 11.3f;
footer.Style.FontName = "Times New Roman";
footer.Style.FontSize = 8f;
footer.Style.HorizontalAlign = AcmHorizontalAlign.Right;
footer.Style.ForegroundColor = Color.LightGray;
render.Render(footer);
}

Hope this will help now!

Thanks
Rahul
eo_support
Posted: Tuesday, March 6, 2012 5:35:02 PM
Rank: Administration
Groups: Administration

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

We are not able to run your code as it. We added the following line at the beginning:

Code: C#
PdfDocument doc = new PdfDocument();


And changed:

Code: C#
AcmRender renderer = new AcmRender(doc, pageLayout);


To:

Code: C#
AcmRender renderer = new AcmRender(doc);


After that the code runs but with the following problem:

1. The first page and the second page are of different size. This is because you called SetDefPageSize on your AcmRender object, but did not apply the same setting on HtmlToPdf.Options.PageSize. Settings for these two are independent, so you must set both;

2. Footer for the first page is fine. However footer for the second page is not visible. Again this is because the code that renders footer and the HTML to PDF converter are using different page sizes;

Hope this helps. Let us know if you still have other problems.

Thanks!
master83
Posted: Tuesday, March 6, 2012 5:55:48 PM
Rank: Member
Groups: Member

Joined: 3/6/2012
Posts: 19
that helped. thanks a lot for support. :)
eo_support
Posted: Tuesday, March 6, 2012 6:52:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Great. Glad that it helped. Feel free to let us know if there is anything else.


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.