Hello there.
First of all, a great product. Has helped us a lot in our organization.
I don’t know if the problems I have can be solved, but somehow I think I use Aspose.Words in the “wrong way”. I suspect there are possibilities to do more things.
My problem is basically to define a document from scratch with styles, headers, etc. I am not using a template, I’m building the doc from the beginning and have been using the aspose tutorials without any luck.
This is how I start off:
// CODE START
// Generate stream with an empty document in HTML format.
Document doc = new Document();
MemoryStream stream = new MemoryStream();
doc.Save(stream, SaveFormat.Html);
// Load the empty HTML document setting the base uri to application path.
doc = new Document(stream, path, LoadFormat.Html, null);
doc.RemoveAllChildren();
Section section = new Section(doc);
doc.AppendChild(section);
section.PageSetup.SectionStart = SectionStart.NewPage;
section.PageSetup.PaperSize = PaperSize.Letter;
Body body = new Body(doc);
section.AppendChild(body);
Paragraph para = new Paragraph(doc);
body.AppendChild(para);
// CODE END
I’ve taken this from the tutorials.
Then I insert different headers like this:
builder.ParagraphFormat.StyleName = "Header 1";
builder.Writeln("1 Test");
builder.ParagraphFormat.StyleName = "Header 2";
builder.Writeln("1.1 Test2");
And below each header I do this:
builder.ParagraphFormat.StyleName = "Normal";
builder.InsertHtml("TEST");
----
Questions:
-
How can I edit my generated document and put my own styles into “Header 1” and “Header 2”? For example, I don’t want them to be Arial and I don’t want “Header 2” to be italic. There must be a way to do this? Remember, I don’t use a template…
-
Whenever I use InsertHtml, and the string contains tables and other basic html junk, builder.ParagraphFormat.LeftIndent does not work!!! If I insert something simple it works, like for example builder.InsertHtml(“blabla”).
I think both of my problems above are because I’ve probably misunderstood something or I am creating my document(or using it?) in the wrong way. Somehow it seems corrupted.
Could someone point me in the right direction here?
best regards
koki