Products Technologies Demo Docs Blog Support Company

Adding Fold Marks and Punch Marks to Documents using Drawings in C#

This article shows how to add fold marks and punch marks to documents using drawings in C#. The sample shows how to create a drawing with fold marks and punch marks and how to add this drawing to a document.

Adding Fold Marks and Punch Marks to Documents using Drawings in C#

Especially important for letters that need to fit into standard envelopes, fold marks are guidelines that help you fold documents accurately. DIN 5008:2011 is a German standard ("Falzmarken") that provides guidelines for document layout and formatting. These marks are used to ensure that when a document is folded, the text will remain in alignment and will fit properly in a standard DL envelope (220 x 110 mm).

Inserting Drawings

To create these marks, you can use the drawing feature of TX Text Control and insert these marks in the header to position them behind the text, overlapping the left margin. The following code shows how to create these fold marks using TX Text Control:

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;
}

The above function can be called to insert the two typical fold marks and a punch mark:

textControl1.Sections.GetItem().HeadersAndFooters.Add(HeaderFooterType.Header);

HeaderFooter header = textControl1.Sections.GetItem().HeadersAndFooters.GetItem(HeaderFooterType.Header);

// folding mark 1
InsertFoldingMark(87, 500, Color.Black, header, textControl1);

// folding mark 2
InsertFoldingMark(192, 500, Color.Black, header, textControl1);

// punch hole center mark
InsertFoldingMark(148.5, 800, Color.Red, header, textControl1);

These fold marks are inserted into the header of the document. The resulting document looks like this:

Folding marks with TX Text Control

Conclusion

Using TX Text Control, you can easily create fold marks for your documents. These marks are especially useful for letters that need to be folded and inserted into standard envelopes. The fold marks are inserted into the header of the document and are positioned behind the text, overlapping the left margin.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETReportingASP.NET Core

C# Document Generation: A Developer's Guide for .NET

Document generation refers to the automatic creation of documents from application data. The success or complexity of a document generation workflow often depends on a single early architectural…


ASP.NETAccessibilityASP.NET Core

Validating PDF/UA Documents in .NET C#: A Practical Guide

This article explains how to validate PDF/UA documents in .NET C# using the TXTextControl.PDF.Validation NuGet package. It shows how to inspect validation status, generate JSON reports, handle…


ASP.NETASP.NET CoreConferences

See Text Control at WeAreDevelopers World Congress Europe 2026 in Berlin

WeAreDevelopers World Congress Europe 2026 is the largest developer conference in Europe. Text Control will be there to showcase our latest products and features. Join us in Berlin from July 9-10,…


ASP.NETASP.NET CoreConferences

DWX 2026 Wrap-Up: Four Days of Innovation, Conversations, and Enterprise…

DWX 2026 was a great success for Text Control. We had the opportunity to meet with many developers, discuss document processing solutions, and showcase our latest innovations in document…


ASP.NETASP.NET CoreeSignatures

Create SignFabric Envelopes from Mail Merge Templates in .NET C#

This article explains how to use TX Text Control to mail merge JSON data into a document template and submit the merged document to the SignFabric API. It shows how your own application can create…

Share on this blog post on: