Child Documents

Hi
I have a couple of questions, that I was unable to find answers for in the documentation. What I am trying to understand is if it is possible to build a document, with “blocks” of documents instead of having one single large document.
1: Is it possible to have one “Master” Aspose.Words (Words), that contain multiple Words documents and Aspose.Cell (Cell) documents?
2: If so, would the Table of Contents work for the Master Document (being that it needed to import the child documents)?
3: Would it be possible to have an Cell Graph in the “Master” document, that would produce prints in vector graphics? (I found a “Sales Report” example (https://demos.aspose.com/), and the Graph in that document is an image).
4: Would it be possible for the Master Words document from question 1. to define the width and height of the Graph inserted (and any other type of document for that matter)?
Thank you in advance!
Best regards
Andreas Nauta Pedersen

Hi Andreas,
Your queries will be better answered by our Aspose.Words team. They will answer the queries and will guide you through. I am moving your post to Aspose.Words forum.
Thanks,

Hi Salman,

Thank you and sorry for the misplacement

Best,
Andreas

Hi

Thanks for your inquiry.

  1. It is not quite clear for me how you would like to insert other document into the master document. If you would like to insert them as embedded OLE objects, then unfortunately, there is no way to achieve this using Aspose.Words.
  2. You can merge all documents into single document, in this case TOC will work for whole document. Please see the following link to learn how to merge documents:
    https://docs.aspose.com/words/net/insert-and-append-documents/
  3. In this Demo we use Aspose.Repors charts, you can save this chart as vector image (EMF) using Save method:
    https://docs.aspose.com/cells/net/chart-to-image/
    and then insert this image into the document.
  4. Do you mean page size of the document? If so, you can specify it using PageSetup:
    https://reference.aspose.com/words/net/aspose.words/pagesetup/papersize/
    Please let me know if you need more assistance, I will be glad to help you.
    Best regards,

Hi Alexey,
Thank you for your reply.
I will try to rephrase: Say we have a document (in this simple example, a single A4 page), that contains both text, table and a graph.
Data for all of this is simple text / numbers coming from a database, but each part (text, table and graph) have its own data source.
So I want to create a single document based on these three “blocks”.
I would need to be able to get data from a database, create a table / graph based on this data, create a vector based image from it and insert this into a placeholder (that defined the width and height of the image when printed) in a Words document.
I guess this placeholder could be a section or paragraph or something like that, that contained the results from Cells / Reports, just something that said: Place this text here, and this image here, and the width of the image is xxx.
1: I dont think this would be OLE objects, it would just be some communication between Words and Cells (and / or Reports).
4: No I mean the internal structure of the document i.e. let the results from Cells go here, let this text go here etc. The Text I can see is possible from the Document Builder Demo (The Paragraph part), but what about the results from Cells?
Best regards
Andreas

Hi Andreas,
Thanks for this additional informaton.
I think you may want to use the InsertDocument method described here instead. The details of how to insert an image using DocumentBuilder here will also help.
If you have any further queries please feel free to ask.
Thanks,

Hi
Thank you for the reply and for the links. I read the documentation there, but I was unable to archive what I am trying to do.
I have added an image so you can see what I am trying to do.
I am properly missing something, but so far I can only find margins on Sections. So what I want to do is embed Sections into each other, in order to have one Section with no margin in the top in a Section defining an A4 document.
I have tried the following code, but that produces 2 separate pages. If I try to add the Section as a child to another Section, I get an error.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);
Section logo = doc.Sections[0];
logo.PageSetup.TopMargin = 0;
logo.PageSetup.LeftMargin = 0;
logo.PageSetup.RightMargin = 0;
logo.PageSetup.PageHeight = 40;

Shape logoShape = new Shape(doc, ShapeType.Rectangle);
logoShape.Width = builder.CurrentSection.PageSetup.PageWidth;
logoShape.Height = builder.CurrentSection.PageSetup.PageHeight;
logoShape.FillColor = Color.Red;
builder.CurrentParagraph.AppendChild(logoShape);

Section firstPage = new Section(doc);
doc.AppendChild(firstPage);
firstPage.PageSetup.SectionStart = SectionStart.NewPage;
firstPage.PageSetup.PaperSize = PaperSize.A4;

doc.Save(@"C:\Test.pdf", SaveFormat.Pdf);

Best regards
Andreas

Hello

Thanks for your request. I suppose in your case it would be better to use Header/Footer conception. Each separate section of the document can have different header/footer. So you can add the same header/footer for each section. Or you can try specifying LinkToPrevious property of section to links or unlinks the specified header or footer to the corresponding header or footer in the previous section. Please see the following link:
https://reference.aspose.com/words/net/aspose.words/headerfootercollection/linktoprevious/
Please see the following link to learn more about creating headers and footers in Aspose.Words:
https://docs.aspose.com/words/net/working-with-headers-and-footers/
Hope this helps.
Best regards,

Hi Andrey
Thank you for your links and suggestion.
I will look into the header and footer, but it is not the whole solution for me.
You can see that attached photo: How would it be possible to place the blue bar?
I am beginning to understand that my only option would be to define a section with no Margins and then use the

  • ParagraphFormat.LeftIndent
  • ParagraphFormat.SpaceBefore
  • ParagraphFormat.SpaceAfter
  • ParagraphFormat.RightIndent

in order to gain control over the placement of the element (Paragraphs), since you cant embed Sections into each other.
The only question that remains is, how you can control the width and height of the Paragraph, so you make fill the entire blue section in the image?
It seems like a bit of a hack, so if I am misunderstanding anything, please let me know. If not I will try to create an example (if it is possible to archive what I want) and post it here for others to see.
Best,
Andreas

Hi

Thanks for your inquiry. I think, in your case it is not required to generate such documents from scratch. I think, it would be better to create template with such layout and then fill this template with data, for example, using Mail Merge approach:
https://docs.aspose.com/words/net/types-of-mail-merge-operations/
I attached template for your reference, and here is simple code to fill it with data:

Document doc = new Document(@"Test001\in.doc");
doc.MailMerge.Execute(new string[] {"FirstName", "LastName"}, new object[] {"Alexey", "Noskov"});
doc.Save(@"Test001\out.doc");

Hope this helps.
Best regards,