We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding Pages

I have several Text files that I want to add to a Document - each Text file needs to be a page in the document. Yes, each text file is small enough to be a page.

How do I do that?

Thanks

Hi Prakash,


Thanks for your inquiry. Please try executing the following draft code to achieve this:

Document doc = new
Document(MyDir + @“in.docx”);

DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln(File.ReadAllText("file1.txt"));

builder.InsertBreak(BreakType.PageBreak);

builder.Writeln(File.ReadAllText("file2.txt"));

builder.InsertBreak(BreakType.PageBreak);

builder.Writeln(File.ReadAllText("file3.txt"));

builder.InsertBreak(BreakType.PageBreak);

builder.Writeln(File.ReadAllText("fileN.txt"));

doc.Save(MyDir + @“out.docx”);


I hope, this helps.

Best regards,