Created
July 19, 2024 14:51
-
-
Save bjoerntx/167b80a5b7ea2cabbe2c0af222781167 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void InsertFoldingMark(double top, int width, Color color, HeaderFooter headerFooter, TextControl textControl) | |
{ | |
textControl.PageUnit = MeasuringUnit.Twips; | |
// create a new drawing control | |
TXTextControl.Drawing.TXDrawingControl drawing = | |
new TXTextControl.Drawing.TXDrawingControl(3000, 1000); | |
// create a new line shape object | |
TXTextControl.Drawing.Shape shape = | |
new TXTextControl.Drawing.Shape(TXTextControl.Drawing.ShapeType.Line); | |
// set the color and border width | |
shape.ShapeOutline.Color = color; | |
shape.ShapeOutline.Width = 20; | |
shape.Angle = -45; | |
shape.Movable = false; | |
shape.Sizable = false; | |
// add the shape to the drawing control | |
drawing.Shapes.Add( | |
shape, | |
TXTextControl.Drawing.ShapeCollection.AddStyle.Fill); | |
shape.Size = new Size(width, width); | |
// create a new drawing frame object from the created drawing control | |
TXTextControl.DataVisualization.DrawingFrame frame = | |
new TXTextControl.DataVisualization.DrawingFrame(drawing); | |
frame.Sizeable = false; | |
frame.Moveable = false; | |
var leftOffset = textControl.Sections[headerFooter.Section].Format.PageMargins.Left - MmToTwips(12); | |
var topOffset = textControl.Sections[headerFooter.Section].Format.PageMargins.Top; | |
// add the frame to the document | |
headerFooter.Drawings.Add( | |
frame, | |
new Point(-(int)leftOffset, | |
(int)(MmToTwips(top) - topOffset)), | |
FrameInsertionMode.BelowTheText | FrameInsertionMode.FixedOnPage); | |
} | |
public static double MmToTwips(double mm) | |
{ | |
const double mmPerInch = 25.4; | |
const double twipsPerInch = 1440; | |
double inches = mm / mmPerInch; | |
double twips = inches * twipsPerInch; | |
return twips; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment