I'm having trouble creating a border around the whole page in a Migra Doc.
I found a posting at
http://stackoverflow.com/questions/8044 ... ge-bordersThat says to use a TextFrame...
Quote:
Drawing a simple rectangle around the whole page should work using e.g. a TextFrame that is added to the page header. TextFrame can have an absolute position, can have any size, and can have a border (width and color can be set).
I found though, that TextFrame does not have a Border property.
Another posting here
viewtopic.php?f=2&t=562&p=1311&hilit=+page+border#p1311says to use a TextFrame, but again, I can't figure out how to proceed from there.
I add a paragraph to the TextFrame, and set a border on that, but the border, only goes around the paragraph...The width of the paragraph is the width of my TextFrame (8 inches), which is good, I can adjust the width and margins of my TextFrame to get the border on the left/right correct, but the paragraph does not extend the whole height of the TextFrame, so I don't know how to get the top/bottom margins to be correct.
Does anyone have a complete code sample? Or any more clues as what to do?
Thanks,
Rich
UPDATE:
Well, after poking around with TextFrame some more, I figure out a solution. I think it's the right one. The problem was that I did not know what a LineFormat was. In this case, setting the LineFormat on the TextFrame, draws a Border. Not sure why this property isn't called Border, like the rest of the objects.
Also, in one of the above postings, it is said to set RelativeHorizontal and RelativeVertical to the Page.
I found that RelativeVertical.Page worked for me.
RelativeHorizontal.Page did not work for me. I would set it, and set frame.Left to a positive number, and the TextFrame border always showed up right up on the left page edge, no matter what I set Left to be.
My workaround was to set RelativeHorizontal.Margin and then set frame.Left to a negative number to move it a bit left of the page margin, so that the border was not right up next to my section elements.
I am not sure if my issue with RelativeHorizontal.Page is a bug or not....
This is for Letter size pages (8.5 in x 11 in), with some narrow margins...
Code:
var frame = section.Headers.Primary.AddTextFrame();
frame.RelativeHorizontal = RelativeHorizontal.Margin;
frame.RelativeVertical = RelativeVertical.Page;
frame.Left = "-.04in";
frame.Top = ".25in";
frame.Width = "7.95in";
frame.Height = "10.1in";
frame.LineFormat.Width = Unit.FromPoint(1);