Extract table from PDF and inset it in a Word document by replacing a placeholder

@awais.hafeez @alexey.noskov Thank you for your continuous support. I have the latest version and the temporary license. The pdf to word conversion works very well. However, I still have issues with placing the extracted table from the word document that was converted from a pdf file. I have a Word.Table.Tables that is provided by a table extractor. This table was extracted from document 1. Now, I want to insert this table into document 2, but I need to search for a piece of text or a bookmark (either works for me, i’m assuming bookmarks are easier to work with) and replace the bookmark with the table. I understand that i need to import the node so I am doing this: var importedNode = Document.ImportNode(tableExtractor.Table, true, ImportFormatMode.KeepSourceFormatting);.
Now, I need to find my bookmark which I can do doing this: Document.Range.Bookmarks[“bookmark”] or use a document builder to do this: builder.MoveToBookmark(“bookmark”). I searched the forum but I cannot find what to do next. If I try builder.InsertNode(importedTable) I get an exception saying this node type cannot be inserted here (this method seems to accept only text nodes).

So if you can help me with this part then I have a working solution. Thank you!

@dustyenterprise You can use Compositenode.InsertAfter or Compositenode.insertbefore method. For example see the following code:

if (tableExtractor.Table != null)
{
    // Put the table into a separate document. Here you can put the table into your template.
    Document testDocument = new Document(@"C:\Temp\in.docx");
    DocumentBuilder builder = new DocumentBuilder(testDocument);

    // Move DocumentBuilder to bookmark.
    builder.MoveToBookmark("myBookmark", true, true);
    // Insert a paragraph.
    builder.Writeln();
    // Insert the table.
    builder.CurrentParagraph.ParentNode.InsertBefore(testDocument.ImportNode(tableExtractor.Table, true), builder.CurrentParagraph);

    // Save the output.
    testDocument.Save(@"C:\Temp\out.docx");
}

@alexey.noskov This really worked! Thank you!
@awais.hafeez Can you talk to the sales team as you suggested? Thanks!

@dustyenterprise

Thank you for your enquiry and for your interest in Aspose.

Normally we would not extend any further discounting for subscription renewals, but we are happy to make an exception in this case and offer a 75% discount instead of the current 40% - this would leave a net sum due of US$749.75.

Kind regards,

George.

Thank you for your offer. While it it is a very good offer I have to decline. As I have stated in an earlier message, there is no budget for an upgrade because the first license purchase was made through a grant. I will be looking at other options for my needs. Thanks for your support so far.

@dustyenterprise

Thank you and I have taken your case to the Business Team. We always like to help when we can and as a ‘one off’ I have extended your licence until tomorrow and this will allow you to use the latest version. The amended licence file will arrive with you shortly by email.
If, in recognition, you would like to provide us with a 500 words Case Study, we would be very glad to receive it.

Kind regards,

George

@GeorgeClark Thank you! This is amazing! It will save me a lot of time. Yes I’d be glad to help out. How do I proceed to offer a case study?

@dustyenterprise

Thank you and that is very good of you. You can find previous submissions at Success Stories - About - aspose.com and you can download the template from https://www.dropbox.com/scl/fi/5vh3osme98y6fkn516zg0/Case_Study_Template.docx?dl=0&rlkey=23lizj54ts73ahufuy9otbw9b

Once completed, could you send it by email to sales@aspose.com and mark it for the attention of me.

Thank you again for supporting Aspose.

Kind regards,

George.