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.

Styling Tables

Thread ID:

Created:

Updated:

Platform:

Replies:

61965 Jun 5,2007 09:46 AM Jun 11,2007 09:20 AM ASP.NET Web Forms (Classic) 5
loading
Tags: PDF
Jeff Becker
Asked On June 5, 2007 09:46 AM

Does Essential PDF support the notion of pre-defined "styles" in any way? It'd be really nice to be able to load up some sort of global table / cell style then apply it across the document?

Sarath Kumar G [Syncfusion]
Replied On June 5, 2007 09:12 PM

Hi Jeffrey,

Thank you for your interest in Syncfusion products.

Currently it is not possible to define built-in pre-defined styles. However, we can work it out by using a Helper function. The Helper function defines formatting styles. We can call this
Helper function such that we can make use of the formatting styles across the document. I have created a sample which explains this criteria.

Here is the sample for your reference.

http://websamples.syncfusion.com/samples/PDF.Windows/F-61965/main.htm

Here is the generated document for your reference;

http://www.syncfusion.com/Support/user/uploads/Sample_2465c0e2.zip

Sample details:
---------------

1) Helper function - "SetStyle", "SetStyle1" takes ITable object and PDFDocument object as parameters. Both the functions are assigned different formatting styles.

2) NorthWind data is assigned to ITable object - table.

3) table calls the helper function SetStyle and table calls SetStyle1, such that the generated PDF document has two tables with two different type of styles.

Please let me know for further help.

Regards,
Sarath

Jeff Becker
Replied On June 7, 2007 11:12 AM

Yeah, I started going down that path only to realize that it would be a unmaintainable nightmare. What I eventually came up with is to create a set of classes which track the CellStyle classes. All the properties of these classes are Nullable. Then I created two interfaces: IAggregatable which aggregates two instances of T using the prefer left most not null method. And IApplyable which applies the style to the cell. From there its pretty trivial to load the various styles, aggregate them and apply them to the cells. I've attached the code as an example should this issue come up in the future.

PDFStyleTemplating.zip

Sarath Kumar G [Syncfusion]
Replied On June 7, 2007 08:17 PM

Hi Jeffrey,

Thank you for the sample file.

I went through the code snippet. I will consult with my development team and will get back to you in two to three business days.

Sorry for the inconvenience caused.

Regards,
Sarath

Jeff Becker
Replied On June 8, 2007 10:51 AM

There seems to be a bug in the PDFColor's handling of custom colors. as a workaround, I've changed the CellStyleTemplate's handling of colors as such

if (_backColor != null)
{
c.Properties.BackColor = new PDFColor(_backColor.Value.R, _backColor.Value.G, _backColor.Value.B);
}
if (_foreColor != null)
{
c.Properties.ForeColor = new PDFColor(_foreColor.Value.R, _foreColor.Value.G, _foreColor.Value.B);
}

Melba Winshia [Syncfusion]
Replied On June 11, 2007 09:20 AM

Hi Jeffrey,

Thank you for the update.

Could you please open a new direct – trac incident with subject line as Forum 61965 - Styling Tables? So that it would be possible for us to provide more details regarding this issue.

Regards,
Melba

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.

;