- Home
- Forum
- ASP.NET Web Forms (Classic)
- Importing a table from a word doc
Importing a table from a word doc
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'
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'
SIGN IN To post a reply.
5 Replies
SS
Sri Subhashini M
Syncfusion Team
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
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
AH
Aaron Hood
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?
SS
Sri Subhashini M
Syncfusion Team
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,
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
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
AH
Aaron Hood
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
It was worth a shot. Thanks
SS
Sri Subhashini M
Syncfusion Team
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
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
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
AH Aaron Hood
- Sep 3, 2009 06:39 PM UTC
- Sep 9, 2009 08:53 AM UTC