Retaining Source Formatting

Hi,
The following is the scenario which we are trying to implement.

There are multiple templates which have dynamic tables(row wise and column wise), conditional insertion of text between the dynamic tables.All these multiple templates need to be collated into a single document which will be the final report. The issue is we have used the following logic.

Document finalDoc = new Document();
// After the above instantiation, do the following

Step 1:Read the reportDoc1, populate this with the dynamic rows and columns.
Step 2:To this object, append the reportDoc1 keeping the source formatting

finalDoc.appendDocument(reportDoc1,ImportFormatMode.KEEP_SOURCE_FORMATTING);

Step 3:Read the reportDoc2, populate this with the dynamic rows and columns. and some dynamic or runtime paragraphs
Step 4:To this object, append the reportDoc2 keeping the source formatting

finalDoc.appendDocument(reportDoc2,ImportFormatMode.KEEP_SOURCE_FORMATTING);

In this case, the problems are

  1. There is a blank page being inserted at the beginning of the final report
  2. The source formatting is not getting copied. For instance, the templates have arial as the font. the output happens to have Times new Roman as the font.

Kindly, let us know why could these problems occur.

Thanks adn Regards,
Pavithra V S

Hi

Thanks for your request.

  1. An empty page occurs at the beginning of the document, because your destination document is not actually empty. When you create new document it already contains one empty section. If you do not need this empty section, you should remove it, as shown below:
Document doc1 = new Document("C:\\Temp\\in1.doc");
Document doc2 = new Document("C:\\Temp\\in2.doc");
Document mainDoc = new Document();
mainDoc.removeAllChildren();
mainDoc.appendDocument(doc2, ImportFormatMode.KEEP_SOURCE_FORMATTING);
mainDoc.appendDocument(doc1, ImportFormatMode.KEEP_SOURCE_FORMATTING);
mainDoc.save("C:\\Temp\\out.doc");
  1. Please attach sample document, which will allow me to reproduce the problem.

Best regards.