The following code creates a PDF document from HTML and outlines
any tagged areas.
var op = new WebPageOperation();
using (op.Doc) {
op.Doc.Rect.Inset(72, 72);
op.Doc.HtmlOptions.AddTags = true;
op.Doc.HtmlOptions.RetryCount = 0;
op.Tagged = true;
op.Outline = true;
string template = "<html><body><div style=\"width:100%;font-size:14pt;text-align:center;\">*</div></body></html>";
op.HeaderHtml = template.Replace("*", "Commentarii de Bello Gallico");
op.FooterHtml = template.Replace("*", "<span class=pageNumber></span> of <span class=totalPages></span>");
op.ReadUrl(GetUrl("commentarii.htm"));
var tagIDs = op.Doc.HtmlOptions.GetTagIDs(op.Doc.Page);
var tagRects = op.Doc.HtmlOptions.GetTagRects(op.Doc.Page);
for (int i = 0; i < tagIDs.Length; ++i) {
op.Doc.Rect.String = tagRects[i].String;
op.Doc.FrameRect();
op.Doc.FontSize = (int)(0.9 * op.Doc.Rect.Height);
op.Doc.AddText(tagIDs[i]);
}
op.Doc.Save(Server.MapPath("webpageop.pdf"));
}
Dim op As New WebPageOperation()
Using op.Doc
op.Doc.Rect.Inset(72, 72)
op.Doc.HtmlOptions.AddTags = True
op.Doc.HtmlOptions.RetryCount = 0
op.Tagged = True
op.Outline = True
Dim template As String = "<html><body><div style=""width:100%;font-size:14pt;text-align:center;"">*</div></body></html>"
op.HeaderHtml = template.Replace("*", "Commentarii de Bello Gallico")
op.FooterHtml = template.Replace("*", "<span class=pageNumber></span> of <span class=totalPages></span>")
op.ReadUrl(GetUrl("commentarii.htm"))
Dim tagIDs As String() = op.Doc.HtmlOptions.GetTagIDs(op.Doc.Page)
Dim tagRects As RectangleF() = op.Doc.HtmlOptions.GetTagRects(op.Doc.Page)
For i As Integer = 0 To tagIDs.Length - 1
op.Doc.Rect.String = tagRects(i).String
op.Doc.FrameRect()
op.Doc.FontSize = CInt(0.9 * op.Doc.Rect.Height)
op.Doc.AddText(tagIDs(i))
Next
op.Doc.Save(Server.MapPath("webpageop.pdf"))
End Using