in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Calculate Height of Text after RenderRichText

Last post 03-19-2008 9:44 AM by M258HBCXFE6D. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 02-19-2008 7:17 AM

    Calculate Height of Text after RenderRichText

    We change our Print-Preview from VB6 to vb.net c1Preview Version 2.0.20072.42005.
    For Formulardesign we have our own Listgenerator. So I must print different kinds of objects in succession. This works fine with RenderImage, Renderline, Rendertext..., but not with RenderRichText. There is a pagebreak after each .ADD and the next Position is on the top of the next page.

    I have tried to get the height of the RTF-Text to calculate the next Y-Position with RenderEmpty, CalcSize ... but nothing works.

    What can I do, and is it also possible to import Word-Files. Thanks         

    ‘--------
    Dim
    fileReader As System.IO.StreamReader
    Dim
    sRTFString As String = ""

    fileReader = My.Computer.FileSystem.OpenTextFileReader(sRTFFile)
    sRTFString = fileReader.ReadToEnd

    Dim rrtf As New RenderRichText

    rrtf.X = uLeft
    rrtf.Y = uTop
    rrtf.Width = uWidth
    rrtf.Rtf = sRTFString
    m_C1DOC.Body.Children.Add(rrtf)

  • 02-19-2008 12:06 PM In reply to

    Re: Calculate Height of Text after RenderRichText

    Try using CalcSize("1In",Cq.CqPreview.Unit.Auto)

    That gives me a height (and 300) for the width.

  • 02-20-2008 11:17 AM In reply to

    Re: Calculate Height of Text after RenderRichText

     Hi, thanks for response. I try CalcSize(Unit.Auto, "1Mm")  but I always get the same value for Height for different RTF-Files.

    There are different values when I try CalcSize(Unit.auto, unit.Auto), but the Value is (after conversion) not the real size of the text.

     

     


     

  • 02-20-2008 1:00 PM In reply to

    Re: Calculate Height of Text after RenderRichText

    It seems that I can get good valuesw for height using

    CalcSize("1in",c1.c1preview.unit.auto)  - I ignore the width resulting from "1in"

    and I get good values for width using

    CalcSize(c1.c1preview.unit.auto,"1in") - again I ignore the height from the "1in"

  • 02-21-2008 5:49 AM In reply to

    Re: Calculate Height of Text after RenderRichText

     Thanks, it works. I have misunderstood your first reply. Is there also a possibility to get the Y Position of the current page after the RTF Text is rendered. I try m_C1DOC.Body.Document.CurrentPage.Y but the Value returned is 0. The vsview7 have a Proberty for this.

    regards
     

  • 02-28-2008 7:27 AM In reply to

    Re: Calculate Height of Text after RenderRichText

     I have attached small example that loads RTF file and uses CalcSize() to determine size of RTF.

    Also it demonstrates properties:AvailableBlockFlowHeight, AvailableBlockFlowWidth and CurrentPageArea. 

  • 02-28-2008 9:33 AM In reply to

    Re: Calculate Height of Text after RenderRichText

    Hi, thanks for reply.

    I try the code from your example in my project and it works fine, but there is one exeption

    Each of my RenderRichText have there own Mesurements   rr.X = uLeft, rr.Y = uTop and  rr.Width = uWidth. The Height I get with calcsize and it works fine.

    But, when I get a Pagebreak the Height of Calcsize is the whole RTFText-Height. And not only the part of the new Page, so I try AvailableBlockFlowHeight to get the available vertical space to calculate my new CurrentY-Position to render some text, graphics, next rtf and so on.

    This works in your sample, when I use the Mesurements I get an Error on RenderBlock: "Object can't be rendered with RenderBlock() method, its coordinares are non auto."  (also in your example)

    When I  use the RenderRichText, I get alway the same Values of AvailableBlockFlowHeight  for each RTFText.

    regards 

  • 02-29-2008 5:57 AM In reply to

    Re: Calculate Height of Text after RenderRichText

    RenderBlock method can be used only when coordinates of object (X and Y) specified as auto. You can use RenderDirect method if you want to render object not in main flow.

    As I have understood you use StartDoc() / Render... / EndDoc() methods to generate a document.
    In this case you can get all measured info directly from object after RenderBlock() or RenderDirectMethod().

     
    I have attached a small example.

     

  • 03-19-2008 9:44 AM In reply to

    Re: Calculate Height of Text after RenderRichText

    Sorry for late reply. Thanks for your help, it works fine. I get all measurements. But the following happens:

    The long text is printed on the second page. The RenderFragment.PageNo is 2 and the Pagecount of the Document is also 2, when I Print the next text with rendertext (also with renderdirect) the text is printet on the first Page ????

     I add rendertext by renderblock in your sample, it works fine! The Text is on the new page, but I can't put the rtftext with y / x position on the page. An error occurs

    With renderdirect i can set the position of the text, but I have the problem describe above

     

    Thanks, regards 

Page 1 of 1 (9 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.