Free Support Forum - aspose.com

PageBreak not working when output to HTML

I have a simple example that shows the problem. It creates a Shape.TextBox on each of three pages. It uses the DocumentBuilder to add a PageBreak between the definition of the three Shape.TextBox instances. The output HTML shows all three TextBox instances overlapping each other with only a small separation. Here is the entire console application to show the issue...

class Program
{
static Document doc = new Document();
static DocumentBuilder builder = new DocumentBuilder(doc);

[STAThreadAttribute()]
static void Main(string[] args)
{
AddTextBox("First Page");
builder.InsertBreak(BreakType.PageBreak);
AddTextBox("Second Page");
builder.InsertBreak(BreakType.PageBreak);
AddTextBox("Third Page");
doc.Save("C:\\out.html");
}

static void AddTextBox(string str)
{
Shape shape = new Shape(doc, ShapeType.TextBox);
shape.Top = 10;
shape.Left = 10;
shape.Width = 200;
shape.Height = 200;

Paragraph paragraph = new Paragraph(doc);
Run run = new Run(doc, str);
run.Font.Underline = Underline.Single;
paragraph.AppendChild(run);
shape.AppendChild(paragraph);
builder.InsertNode(shape);
}
}

Hi

Thanks for your request. As you may know, there are no pages in HTML. HTML document contain one page. In your case, I think, you should simply use inline Textboxes. In this case, they will not overlap each other.

static void AddTextBox(string str)

{

Shape shape = new Shape(doc, ShapeType.TextBox);

shape.Top = 10;

shape.Left = 10;

shape.Width = 200;

shape.Height = 200;

shape.WrapType = WrapType.Inline;

Paragraph paragraph = new Paragraph(doc);

Run run = new Run(doc, str);

run.Font.Underline = Underline.Single;

paragraph.AppendChild(run);

shape.AppendChild(paragraph);

builder.InsertNode(shape);

}

Hope this helps.

Best regards,