We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

'Div' within table - row - cell using Aspose.Pdf.Text

Hi
I am trying to create the below in pdf…
The only thing i cant seem to create is the blue chart area. I have tried using a Div and setting width but doesnt seem to work…I have also tried playing with the margins of the Aspose.Pdf.Text but no luck…

note: I have to dynamically create these values, so cant use InLineHtml route.

Is this possible and if so, how ?
Many Thanks
Mark




Hi Mark,

Can you please share some details regarding sample source code and template documents you are using or create a sample application to show the issue. This will help us to figure out the issue and reply back to you soon.

We apologize for your inconvenience.

Thanks & Regards,

Hi
see my code…
The code highlighted in red is the bit i am having problems with. Each

needs to display a blue background.
For html_dcol it needs to be 100% of its cell width.
For html_dcol2 it needs to be 50% of its cell width.


Hope this is clear :wink:

Mark
------
Pdf _pdf = new Pdf();
Section sec1 = _pdf.Sections.Add();

Text html_title = new Text("<font face=“Verdana” size=10>Sales") { IsHtmlTagSupported = true };
sec1.Paragraphs.Add(html_title);

Text html_hcol1 = new Text("<font face=“Verdana” size=8>Group") { IsHtmlTagSupported = true, Margin = { Left = 5, Right = 5, Top = 0, Bottom = 0 } };
Text html_hcol2 = new Text("<font face=“Verdana” size=8>Cost") { IsHtmlTagSupported = true, Margin = { Left = 5, Right = 5, Top = 0, Bottom = 0 } };

Table _table = new Table();
sec1.Paragraphs.Add(_table);
//set the column widths of the table
_table.ColumnWidths = “120 80 50 80 80”;
_table.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.05F, new Color(“Silver”));
_table.DefaultCellTextInfo.FontName = “Verdana”;
_table.DefaultCellTextInfo.FontSize = 8;
_table.DefaultCellPadding.Bottom = 0;
_table.DefaultCellPadding.Top = 0;
_table.Margin.Bottom = 0;
_table.Margin.Top = 0;
_table.Margin.Left = 0;
_table.Margin.Right = 0;

// Add Header row
Row _row = _table.Rows.Add();
_row.Cells.Add().Paragraphs.Add(html_hcol1);
_row.Cells.Add().Paragraphs.Add(html_hcol2);

int i = 0;
Row _drow1 = _table.Rows.Add();
Text html_group = new Text(string.Format("<font face=“Verdana” size=8>{0}", “North”)) { IsHtmlTagSupported = true, Margin = { Left = 5, Right = 5 } };
Text html_dcol = new Text("
") { IsHtmlTagSupported = true, Margin = { Left = 5, Right = 5 } };
_drow1.Cells.Add().Paragraphs.Add(html_group);
_drow1.Cells.Add().Paragraphs.Add(html_dcol);

Row _drow2 = _table.Rows.Add();
Text html_group2 = new Text(string.Format("<font face=“Verdana” size=8>{0}", “South”)) { IsHtmlTagSupported = true, Margin = { Left = 5, Right = 5 } };
Text html_dcol2 = new Text("
") { IsHtmlTagSupported = true, Margin = { Left = 5, Right = 5 } };
_drow2.Cells.Add().Paragraphs.Add(html_group2);
_drow2.Cells.Add().Paragraphs.Add(html_dcol2);


_pdf.Save(“DDIGroupOverviewExport.pdf”, SaveType.OpenInAcrobat, context.Response);
}

Hi Mark,

You can use the "

" tag to display background in blue color and for highlight 50% of the column, you can use CSS.

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

Hi

Have already tried this and it does not work !

Row _drow = _table.Rows.Add();

Text html_dcol = new Text("

")

{IsHtmlTagSupported = true}

_drow.Cells.Add().Paragraphs.Add(html_dcol);

Thanks

Mark

Hi Mark,

Sorry for your inconvenience.

I have tested the scenario with above mentioned source code using Aspose.Pdf for .NET version 6.5.0.0. Kindly use the latest version and try it again, you can download it from here.

For your reference, I have also attached the resultant PDF that I have generated.

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

Hi
Do i need to purchase a licence for this?
I have a licence for our old version of aspose.pdf.

I can manage to create the bar, but struggling with the resizing. Are you able to create 1 bar (row) with 100% and another bar(row) at 50% ??

Many Thanks
Mark

Hi Mark,

Thank you for considering Aspose.Pdf.

If you already have a valid license for Aspose.Pdf then no need to purchase the license again, just download and use the latest version of Aspose.Pdf. You can download it from here.

Moreover, you can set background color within the

tag, which applies for the 100% of the
area. For more details, kindly visit the below mentioned links:

http://www.hscripts.com/tutorials/css/backp5.php

http://www.htmlcodes.me/color/html-color-code-generator.cfm?hexColor=FF7F50

Please free to contact support in case you need any further assistance.

Thanks & Regards,


Hi
Thanks that appears to have worked.
However,i am having problems with the licensing of dll…

License _pdflicence = new License();
_pdflicence.SetLicense(“Aspose.Pdf.lic”);

Does not seem to work?
Yet it works for my old version…

Thanks
Mark

Hi Mark,

Kindly place this file "Aspose.Pdf.lic" any where in your computer and access using absolute path as mentioned below:

license.SetLicense(@"D:\Aspose.Pdf.lic");

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

Hi
I can create the DIV within the cell, but it does not seem to recognise “width” within the style.
Whatever i set this to (eg; 10%) it just fills the whole cell with the ‘blue’ DIV

Text html_dcol =
new Text("<div style=“background-color: #5A7998; width: 5%;”>" + “Cost” + “”)
{
IsHtmlTagSupported = true,
Margin = { Left = 5, Right = 5 }
};

Any ideas?
Thanks
Mark

Any ideas on how to get this to work please?

thanks
Mark

Hi Mark,

First of all, I apologies for the delay in responce.

You are going to set background color within the

tag, which always apply for the 100% of the
area. You can not set 5% or 10% width of background color within the div tag directly. For more details, kindly visit the below mentioned links:

http://www.hscripts.com/tutorials/css/backp5.php

http://www.htmlcodes.me/color/html-color-code-generator.cfm?hexColor=FF7F50

Please free to contact support in case you need any further assistance.

Thanks & Regards,