We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Text is overlapping

Thread ID:

Created:

Updated:

Platform:

Replies:

88925 Aug 14,2009 10:03 AM Sep 2,2009 06:40 AM ASP.NET Web Forms (Classic) 4
loading
Tags: PDF
pegaso
Asked On August 14, 2009 10:03 AM

Hi, in my code the PdfLayoutType.Paginate don't work fine. In foreach loop I've very large text but the new bottoms bounds is wrong and the text is overlapping.

Thank you

This is the code:

......

PdfLayoutFormat layoutFormat = new PdfLayoutFormat();
layoutFormat.Break = PdfLayoutBreakType.FitPage;
layoutFormat.Layout = PdfLayoutType.Paginate;

RectangleF bounds = new RectangleF(new PointF(0, 10), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));

PdfTextLayoutResult result = element.Draw(page, bounds, layoutFormat);

element.Font = Font_Regular14;
element.StringFormat = SF_Titolo;
element.Text = _myText;

bounds = new RectangleF(new PointF(0, result.LastLineBounds.Y + 20), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));

result = element.Draw(page, bounds, layoutFormat);

foreach (DataRow Dr in Dt.Rows)
{
bounds = new RectangleF(new PointF(0, result.LastLineBounds.Y + 20), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));

element.Font = Font_Bold11;
element.StringFormat = SF_Titolo;
element.Text = Dr["obb"].ToString();

result = element.Draw(page, bounds, layoutFormat);

bounds = new RectangleF(new PointF(0, result.LastLineBounds.Y + 10), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));

element.Font = Font_Regular11;
element.StringFormat = SF_Testo;
element.Text = Dr["dispo"].ToString();

result = element.Draw(page, bounds, layoutFormat);
}

Thiruvenkadam E [Syncfusion]
Replied On August 18, 2009 11:31 AM

Hi pegaso,

Thank you for your interest in Syncfusion products,

Text is overlapping

We can able to avoid the text overlapping by using PdfTextLayoutResult.Remainder property.

Kindly refer the below code snippet which helps to avoid the text overlapping.

[c#]

........

RectangleF bounds = new RectangleF(new PointF(0, 10), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));

foreach (DataRow Dr in Dt.Rows)
{
bounds = new RectangleF(new PointF(0, result.LastLineBounds.Y + 20), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));

element.Font = Font_Bold11;
element.StringFormat = SF_Titolo;
element.Text = Dr["obb"].ToString();

result = element.Draw(page, bounds, layoutFormat);

bounds = new RectangleF(new PointF(0, result.LastLineBounds.Y + 10), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));

element.Font = Font_Regular11;
element.StringFormat = SF_Testo;
element.Text = Dr["dispo"].ToString();

result = element.Draw(page, bounds, layoutFormat);

if ((result.Remainder != null) && (result.Remainder.Length > 0))
{
page = doc.Pages.Add();
bounds = new RectangleF(new PointF(0, 10), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));
element.Text = result.Remainder;
result = element.Draw(page, bounds.Location, bounds.Width, layoutFormat);
}

}

Please do find the sample from the below specified location which demonstrates how to avoid the text overlapping and let us know if this helps,

http://files.syncfusion.com/support/PDF.Web/F88925/F88925.zip

Regards,
Thiru


pegaso
Replied On August 24, 2009 04:51 AM

Hi Thiruvenkadam,
sorry but your example don't work fine. The result.Remainder always return null value and the text is overlapping. Can you try the example in attachment?

Thank you.



my_example_b9cef4fb.zip

pegaso
Replied On August 24, 2009 09:51 AM

...this is the solution:

result = element.Draw(doc.Pages[doc.Pages.Count - 1],...

bye bye

Thiruvenkadam E [Syncfusion]
Replied On September 2, 2009 06:40 AM

Hi pegaso,

I am sorry for the inconvenience caused.

Text is overlapping

We can able to avoid the text overlapping by using PdfTextLayoutResult.Remainder property.

Kindly refer the below code snippet which helps to avoid the text overlapping.


foreach (DataRow Dr in Dt.Rows)
{
bounds = new RectangleF(new PointF(0, result.LastLineBounds.Y + 20), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));
element.Font = Font_Bold11;
element.StringFormat = SF_Titolo;
element.Text = Dr["obb"].ToString();
result = element.Draw(page, bounds.Location, bounds.Width, layoutFormat);
if ((result.Remainder != null) && (result.Remainder.Length > 0))
{
page = doc.Pages.Add();
bounds = new RectangleF(new PointF(0, 10), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));
element.Text = result.Remainder;
result = element.Draw(page, bounds.Location, bounds.Width, layoutFormat);
}
else
{
page = result.Page;
bounds = new RectangleF(new PointF(0, result.LastLineBounds.Y + 10), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));
}
bounds = new RectangleF(new PointF(0, result.LastLineBounds.Y + 10), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));
element.Font = Font_Regular11;
element.StringFormat = SF_Testo;
element.Text = Dr["dis"].ToString();
result = element.Draw(page, bounds.Location, bounds.Width, layoutFormat);
if ((result.Remainder != null) && (result.Remainder.Length > 0))
{
page = doc.Pages.Add();
bounds = new RectangleF(new PointF(0, 10), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));
element.Text = result.Remainder;
result = element.Draw(page, bounds.Location, bounds.Width, layoutFormat);
}
else
{
page = result.Page;
bounds = new RectangleF(new PointF(0, result.LastLineBounds.Y + 10), new SizeF(page.Graphics.ClientSize.Width - 20, page.Graphics.ClientSize.Height - 10));
}
}


Please do find the sample from the below specified location which demonstrates how to avoid the text overlapping and let us know if this helps,

http://files.syncfusion.com/support/PDF.Web/F88925/Sample.zip

Regards,
Thiru

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;