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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Importing a table from a word doc

Thread ID:

Created:

Updated:

Platform:

Replies:

89730 Sep 3,2009 06:39 PM UTC Sep 9,2009 08:53 AM UTC ASP.NET Web Forms (Classic) 5
loading
Tags: PDF
Aaron Hood
Asked On September 3, 2009 06:39 PM UTC

I want to import a table from a word doc into a pdf section. How would I go about doing this?

Here is what I have so far...

PdfDocument doc = new PdfDocument();
PdfSection section = doc.Sections.Add();
PdfPage page = section.Pages.Add();
PdfGraphics g = doc.Pages[0].Graphics;

WordDocument wordDoc = new WordDocument("Test.doc"); //Works
IWTable table = wordDoc.Sections[0].Tables[0]; //Works

//No idea how to draw var 'table' into var 'section'


Sri Subhashini M [Syncfusion]
Replied On September 4, 2009 10:08 AM UTC

Hi Asron,

Thank you for your interest in Essential PDF.

Convert table from Word to PDF document

We can convert a table in word into a PDF document by drawing the table in a word document and convert the word document as a PDF using DoctoPDF converter.

Could you please do find the sample from the below specified location and let me know if you need further assistance?

http://files.syncfusion.com/samples/PDF.Windows/PDF_Win_F89730.zip

Regards,
Suba

Aaron Hood
Replied On September 4, 2009 03:28 PM UTC

I do not want to convert the whole doc to pdf. I would like to grab a table from the doc and redraw it into another pdf that I'm creating on the fly. Is that possible?

Sri Subhashini M [Syncfusion]
Replied On September 7, 2009 06:50 AM UTC

Hi Aaron,

Convert table from Word to PDF document

It is not directly not possible to convert a specific table in a word document as a PDF document. But we can achieve the same feature by following the below mentioned steps,

1. Convert the table from a word document as a DataTable.
2. Set the DataTable to the PdfDocument`s PdfLightTable DataSource object.
3. Draw the PdfLightTable in a PdfDocument.

Kindly look into the below specific code which converts the existing word document`s table as DataTable,


IWTable table = document.Sections[0].Tables[0];
// Convert the existing table as DataTable
DataTable dt = new DataTable("dt");
for (int i = 0; i < table.FirstRow.Cells.Count; i++)
dt.Columns.Add(table.FirstRow.Cells[i].Paragraphs[0].Text);

for (int i = 0; i < table.Rows.Count; i++)
{
string[] s = new string[dt.Columns.Count];
for (int j = 0; j < table.Rows[i].Cells.Count; j++)
{
s[j] = table.Rows[i].Cells[j].Paragraphs[0].Text;
}
dt.Rows.Add(s);
}


Could you please do find the sample which demonstrates the above mentioned feature and let me know if this helps?

http://files.syncfusion.com/samples/PDF.Windows/PDF_Win_F89730_Modified.zip

Regards,
Suba

Aaron Hood
Replied On September 8, 2009 03:55 PM UTC

Converting it to a datatable would work to get the data but I loose the main purpose of the conversation. The reason I wanted to grab the table object directly was to keep the layout and formating.

It was worth a shot. Thanks

Sri Subhashini M [Syncfusion]
Replied On September 9, 2009 08:53 AM UTC

Hi Aaron,

As we mentioned earlier, it is not possible to grap the table object from a word document. But you can format or customize the cells in PdfLightTable with the help of the PdfCellStyle.

Could you please refer the below webpage for more information about PdfLightTable and let me know if you need further assistance?

http://help.syncfusion.com/ug_73/pdf/Tables.html

Regards,
Suba

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.

Warning Icon 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.Close Icon

;