C1.C1Report.4 Assembly > C1.C1Preview Namespace > RenderObject Class : CalcSize Method |
C1PrintDocument doc = new C1PrintDocument(); doc.StartDoc(); RenderText rt = new RenderText("The text to measure.); // add the object temporarily to calculate its size: doc.Body.Children.Add(rt); // measure the object, specifying page width and auto heigh // (i.e. effectively, measure the text height): C1PageSettings ps = doc.PageLayout.PageSettings; double pageWidth = ps.Width.Value - ps.LeftMargin.Value - ps.RightMargin.Value; SizeD sz = rt.CalcSize(new Unit(pageWidth, ps.Width.Units), Unit.Auto); // remove the object added temporarily: doc.Body.Children.Remove(rt); // test whether the object would fit on the page: if (doc.AvailableBlockFlowHeight >= sz.Height) { // object would fit, do something: doc.RenderBlockText("YES"); } doc.EndDoc();
C1PrintDocument doc = new C1PrintDocument(); doc.StartDoc(); RenderText rt = new RenderText("The text to measure.); // add the object temporarily to calculate its size: doc.Body.Children.Add(rt); // measure the object, specifying page width and auto heigh // (i.e. effectively, measure the text height): C1PageSettings ps = doc.PageLayout.PageSettings; double pageWidth = ps.Width.Value - ps.LeftMargin.Value - ps.RightMargin.Value; SizeD sz = rt.CalcSize(new Unit(pageWidth, ps.Width.Units), Unit.Auto); // remove the object added temporarily: doc.Body.Children.Remove(rt); // test whether the object would fit on the page: if (doc.AvailableBlockFlowHeight >= sz.Height) { // object would fit, do something: doc.RenderBlockText("YES"); } doc.EndDoc();