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. Image for the cookie policy date

Styling Tables

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?

5 Replies

SK Sarath Kumar G Syncfusion Team June 6, 2007 01:12 AM UTC

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


JB Jeff Becker June 7, 2007 03:12 PM UTC

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


SK Sarath Kumar G Syncfusion Team June 8, 2007 12:17 AM UTC

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


JB Jeff Becker June 8, 2007 02:51 PM UTC

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);
}


MW Melba Winshia Syncfusion Team June 11, 2007 01:20 PM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon