Sign In  Sign Up Live-Chat

TextInfo.TextBorder of a Text paragraph merges with subsequent borders of text paragraph's

Last post 09-04-2007, 12:12 AM by Hans.firefox. 2 replies.
Sort Posts: Previous Next
  •  08-28-2007, 3:22 AM 92508

    TextInfo.TextBorder of a Text paragraph merges with subsequent borders of text paragraph's

    Im doing some testing with aspose.pdf and I am having problems with generating text areas with a border surrounding the text. As you can see from the code I have a function that adds a text paragraph with the TextInfo.TextBorder set, to a section. The problem is that if I add multiple text paragraph's to a section using the function, all the text paragraphs share the same TextBorder, and does not surround the individual paragraphs I added. The paragraph and the text border is also cut/broken at page break.

    This was run in a visual studio 2005 asp.net project.

    I find it unintuitive that the border area is merged considering that I am adding individual Text paragraphs with individual borders. And the aspose.pdf documentation is poor to say the least.

    // CODE FOLLOWS

    // This is the function that add a Text paragraph and set the TextInfo.TextBorder

    private void AddTextWithTitleStandard(string title, string content, Section section1)

    {

    Text text1 = new Text(section1);

    BorderInfo text1Border = new BorderInfo((int)BorderSide.All, 2, new Color(84, 84, 84));

    text1.TextInfo.TextBorder = text1Border;

    text1.Margin.Top = 10;

    //text1.Margin.Left = 1;

    //text1.Margin.Right = 1;

    text1.Margin.Bottom = 10;

    text1.TextInfo.Color = new Color("Black");


    Segment header1 = new Segment(text1);

    header1.TextInfo.FontSize = 16;

    header1.TextInfo.IsTrueTypeFontBold = true;

    header1.Content = title + "\r\n";


    Segment content1 = new Segment(text1);

    content1.Content = content;

    text1.Segments.Add(header1);

    text1.Segments.Add(content1);

    text1.IsKeptTogether = true;

    text1.IsKeptWithNext = false;

    section1.Paragraphs.Add(text1);

    }

    private void InitializePdf(Pdf pdf1)

    {

    BorderInfo bi = new BorderInfo((int)BorderSide.All, 2, new Color("Black"));

    pdf1.PageSetup.Margin.Top = 40;

    pdf1.PageSetup.Margin.Left = 1;

    pdf1.PageSetup.Margin.Right = 1;

    pdf1.PageSetup.Margin.Bottom = 1;

    pdf1.PageSetup.PageBorder = bi;

    pdf1.PageSetup.PageBorderMargin.Top = 60;

    Security s = new Security();

    s.Is128BitsEncrypted = true;

    s.IsContentsModifyingAllowed = false;

    pdf1.Security = s;

    }

    private void InitializeSection(Section section1)

    {

    BorderInfo bi = new BorderInfo((int)BorderSide.All, 2, new Color("Black"));

    HeaderFooter mainHeader = new HeaderFooter(section1);

    HeaderFooter mainFooter = new HeaderFooter(section1);

    Aspose.Pdf.Image headerImage = new Aspose.Pdf.Image(mainHeader);

    headerImage.ZIndex = -1;

    headerImage.Margin.Top = 20;

    headerImage.ImageInfo.Alignment = AlignmentType.Center;

    headerImage.ImageInfo.File = Server.MapPath("lvtfetop.jpg");

    headerImage.ImageInfo.ImageFileType = ImageFileType.Jpeg;

    Graph footGraph = new Graph(mainFooter);

    Rectangle footRect = new Rectangle(0, 12, 560, 10);

    footGraph.Shapes.Add(footRect);

    footRect.GraphInfo.IsFilled = true;

    footRect.GraphInfo.FillColor = new Color("Black");

    section1.EvenHeader = mainHeader;

    section1.OddHeader = mainHeader;

    section1.EvenFooter = mainFooter;

    section1.OddFooter = mainFooter;

    section1.PageInfo.PageBorder = bi;

    section1.PageInfo.PageBorderMargin.Top = 60;

    section1.PageInfo.PageBorderMargin.Left = 20;

    section1.PageInfo.PageBorderMargin.Right = 20;

    section1.PageInfo.PageBorderMargin.Bottom = 40;

    section1.PageInfo.Margin.Left = 40;

    section1.PageInfo.Margin.Right = 40;

    mainHeader.Paragraphs.Add(headerImage);

     


    }

    // This is the "Main" code

            string pdffilename = "pdftest.pdf";
            string pdfpathmap = Server.MapPath(pdffilename);

            Pdf pdf1 = new Pdf();

            Section section1 = pdf1.Sections.Add();

            InitializePdf(pdf1);
           
            InitializeSection(section1);

            AddTextWithTitleStandard("2. THIS IS A TEST TITLE - TEXT AREA", "This is some content\r\nThis is more content", section1);
            AddTextWithTitleStandard("2. THIS IS A TEST TITLE - TEXT AREA", "This is some content\r\nThis is more content", section1);
            AddTextWithTitleStandard("2. THIS IS A TEST TITLE - TEXT AREA", "This is some content\r\nThis is more content", section1);
            AddTextWithTitleStandard("2. THIS IS A TEST TITLE - TEXT AREA", "This is some content\r\nThis is more content", section1);
            AddTextWithTitleStandard("2. THIS IS A TEST TITLE - TEXT AREA", "This is some content\r\nThis is more content", section1);
            AddTextWithTitleStandard("2. THIS IS A TEST TITLE - TEXT AREA", "This is some content\r\nThis is more content", section1);
            AddTextWithTitleStandard("2. THIS IS A TEST TITLE - TEXT AREA", "This is some content\r\nThis is more content", section1);
            AddTextWithTitleStandard("2. THIS IS A TEST TITLE - TEXT AREA", "This is some content\r\nThis is more content", section1);
            AddTextWithTitleStandard("2. THIS IS A TEST TITLE - TEXT AREA", "This is some content\r\nThis is more content", section1);

            pdf1.Save(pdfpathmap);

     
  •  08-28-2007, 4:58 PM 92642 in reply to 92508

    Re: TextInfo.TextBorder of a Text paragraph merges with subsequent borders of text paragraph's

    Hi,

    Thank you for considering Aspose.

    I think probably it is a bug. I have logged this issue as PDFNET-3664. I will discuss this with the developers and we will let you know as soon as solution is found.

    Thanks.
     
  •  09-04-2007, 12:12 AM 93305 in reply to 92508

    Re: TextInfo.TextBorder of a Text paragraph merges with subsequent borders of text paragraph's

    Attachment: Present (inaccessible)
    Hi,

    In MS Word, If adjacent texts have TextBorders and their TextBorders' formats (including TextBorder style, color and line width) are the same, the first text's bottom side, the last text's top side and other middle texts' both top sides and bottom sides will be removed. These texts look like all in one table cell.
    Howerve, if two texts have differnt TextBorder formats, all the sides shoudle remain.

    Our design is based on this. I think it's not a bug. But still one problem exists.  In old version, TextBorders' formats were ignored when merging TextBorders. And it result in texts with differnt TextBorder formats losing top or bottom sides of their TextBorders. Now,the problem is resolved. Please try the attached dll before we publish the hotfix.

    Best regards.
    Hans

    Hans Zhang
    Product Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
View as RSS news feed in XML