Quantcast
Channel: PDF tips & tricks
Viewing all articles
Browse latest Browse all 125

How to create round-rect borders in PDF

$
0
0

Introduction


You can create cool visual effects using the flow layout API provided by Apitron PDF Kit. One of such effects is the support border-radius property offered by content elements. This property can be used to create round-rect borders for text, images and even annotation objects.

Code sample


staticvoid Main(string[] args)
{
    // create document and its resource manager
    ResourceManager manager = newResourceManager();
    FlowDocument doc = newFlowDocument(){Margin = newThickness(10)};

    // add new text block with roudn-rect border
    doc.Add(newTextBlock("The text with round-rect border")
            {
                BorderRadius = 5,
                Border = newBorder(10),
                BorderColor = RgbColors.Red,
                Padding = newThickness(5)
            });

    // save file
    using (Stream stream = File.Create("round-rect.pdf"))
    {
        doc.Write(stream, manager);
    }
}


Resulting image is shown below:

Pic. 1 Text block with round-rect border

Pic. 1Text block with round-rect border

Conclusion


Flow layout API offered by the Apitron PDF Kit .NETcomponent can be used to quickly design and generate PDF documents in a way similar to HTML/CSS approach. It works on multiple platforms including Windows Phone, Xamarin, MONO. Create mobile, web and desktop PDF processing apps using this new generation of PDF creation tools.

Viewing all articles
Browse latest Browse all 125

Trending Articles