Print RTF spanning multiple pages - Programmer

This is a discussion on Print RTF spanning multiple pages - Programmer ; Hi, My application uses a RTF file to report the results of an execution. This report file can be printed out automatically or saved for future purposes. The content of the RTF report file is very diverse: text in different ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Print RTF spanning multiple pages

  1. Print RTF spanning multiple pages

    Hi,

    My application uses a RTF file to report the results of an execution.
    This report file can be printed out automatically or saved for future
    purposes. The content of the RTF report file is very diverse: text in
    different fonts and colors, pictures, tables, ... When I create the
    RTF file I set its page width to the maximum (up to 5 times a normal
    A4 width) so that ever large objects (tables or pictures) can be
    displayed correctly.

    I run into problems when the content I want to print out is wider than
    one physical page: a long line of text gets 'word wrapped' to the next
    line(s) instead of continuing, a picture gets cut off when its hits
    the border of the page.

    I would like to have the RTF print out like an excel sheet does: when
    the content is too wide, excel prints another page next to the
    previous one to show the content that could not be display on the
    first page. That way there are not only pages from top to bottom but
    also from left to right.

    A possible solution would be to import the RTF in excel to print it
    out, but excel has a stupid limitation to show only the first page (in
    the vertical dimension) and (I think) there's no way to work around
    that.

    Does anyone know how to print out an RTF file in the two dimensions?
    Perhaps some control or a piece of code (C, C#, VB) ...


    Thanks,
    Sven

  2. Re: Print RTF spanning multiple pages


    "PP" wrote in message
    news:1cd4466a.0311040652.7175c69@posting.google.co m...
    > Hi,
    >
    > My application uses a RTF file to report the results of an execution.
    > This report file can be printed out automatically or saved for future
    > purposes. The content of the RTF report file is very diverse: text in
    > different fonts and colors, pictures, tables, ... When I create the
    > RTF file I set its page width to the maximum (up to 5 times a normal
    > A4 width) so that ever large objects (tables or pictures) can be
    > displayed correctly.
    >
    > I run into problems when the content I want to print out is wider than
    > one physical page: a long line of text gets 'word wrapped' to the next
    > line(s) instead of continuing, a picture gets cut off when its hits
    > the border of the page.


    You could render to a bitmap of the appropriate size (5 pages wide by
    one tall) and print the bitmap in sections the way you want it.

    Nathan Holt




  3. Re: Print RTF spanning multiple pages

    I am not 100% sure if there is a better way or not, but this is how I would
    go about doing it. I would get the printer dc. get the widht and hight of
    each page. Draw my entire document into a very large DC and bitblt it from
    different offset into the printer dc.
    Something like this
    1.create a memory dc.
    2.create a bitmap using the width and height of the text in the file
    3.draw the text into the dc using the RichCtrls drawing routines.
    4.get a printer dc
    5. draw onto the dc
    int NumPages = BitmapHeight / PageHeight; //of course you will need
    to handle a half page!!!
    int NumWidthPages = BitmapWidth / PageWidth
    Y = 0;
    PrinterDC.StartDoc();
    for (int i = 0; i < NumPages;i++)
    {
    X = 0;
    for (int j = 0; j < NumWidthPages;j++)
    {
    PrinterDC.StartPage();
    PrinterDC.bitblt(0,0,PageWidth,PageHeight,MEMDC,X, Y,SRCCOPY);
    PrinterDC.EndPage();
    X += PageWidth;
    }
    Y += PageHeight;
    }
    PrinterDC.EndDoc();

    I hope this helps

    Ali R.

    "PP" wrote in message
    news:1cd4466a.0311040652.7175c69@posting.google.co m...
    > Hi,
    >
    > My application uses a RTF file to report the results of an execution.
    > This report file can be printed out automatically or saved for future
    > purposes. The content of the RTF report file is very diverse: text in
    > different fonts and colors, pictures, tables, ... When I create the
    > RTF file I set its page width to the maximum (up to 5 times a normal
    > A4 width) so that ever large objects (tables or pictures) can be
    > displayed correctly.
    >
    > I run into problems when the content I want to print out is wider than
    > one physical page: a long line of text gets 'word wrapped' to the next
    > line(s) instead of continuing, a picture gets cut off when its hits
    > the border of the page.
    >
    > I would like to have the RTF print out like an excel sheet does: when
    > the content is too wide, excel prints another page next to the
    > previous one to show the content that could not be display on the
    > first page. That way there are not only pages from top to bottom but
    > also from left to right.
    >
    > A possible solution would be to import the RTF in excel to print it
    > out, but excel has a stupid limitation to show only the first page (in
    > the vertical dimension) and (I think) there's no way to work around
    > that.
    >
    > Does anyone know how to print out an RTF file in the two dimensions?
    > Perhaps some control or a piece of code (C, C#, VB) ...
    >
    >
    > Thanks,
    > Sven




  4. Re: Print RTF spanning multiple pages

    > My application uses a RTF file to report the results of an execution.
    > This report file can be printed out automatically or saved for future
    > purposes. The content of the RTF report file is very diverse: text in
    > different fonts and colors, pictures, tables, ... When I create the
    > RTF file I set its page width to the maximum (up to 5 times a normal
    > A4 width) so that ever large objects (tables or pictures) can be
    > displayed correctly.
    >
    > I run into problems when the content I want to print out is wider than
    > one physical page: a long line of text gets 'word wrapped' to the next
    > line(s) instead of continuing, a picture gets cut off when its hits
    > the border of the page.
    >
    > I would like to have the RTF print out like an excel sheet does: when
    > the content is too wide, excel prints another page next to the
    > previous one to show the content that could not be display on the
    > first page. That way there are not only pages from top to bottom but
    > also from left to right.
    >
    > A possible solution would be to import the RTF in excel to print it
    > out, but excel has a stupid limitation to show only the first page (in
    > the vertical dimension) and (I think) there's no way to work around
    > that.
    >
    > Does anyone know how to print out an RTF file in the two dimensions?
    > Perhaps some control or a piece of code (C, C#, VB) ...


    I haven't used this code myself, and I'm not entirely sure it can be made to
    do what you want, but you might want to check it out anyway...

    http://support.microsoft.com/default...b;en-us;146022

    Rick - MVP



  5. Re: Print RTF spanning multiple pages

    "Ali R." wrote in message news:...
    > I am not 100% sure if there is a better way or not, but this is how I would
    > go about doing it. I would get the printer dc. get the widht and hight of
    > each page. Draw my entire document into a very large DC and bitblt it from
    > different offset into the printer dc.
    > Something like this
    > 1.create a memory dc.
    > 2.create a bitmap using the width and height of the text in the file
    > 3.draw the text into the dc using the RichCtrls drawing routines.


    How can I draw the text (and pictures) in the dc? I don't understand
    what you mean by 'the RichCtrls drawing routines'.


    Sven

  6. Re: Print RTF spanning multiple pages

    You can use CRichEditCtrl::FormatRange to print to a particular dc in the
    formating you want.

    Ali R.

    "PP" wrote in message
    news:1cd4466a.0311050744.5a9ff100@posting.google.c om...
    > "Ali R." wrote in message

    news:...
    > > I am not 100% sure if there is a better way or not, but this is how I

    would
    > > go about doing it. I would get the printer dc. get the widht and hight

    of
    > > each page. Draw my entire document into a very large DC and bitblt it

    from
    > > different offset into the printer dc.
    > > Something like this
    > > 1.create a memory dc.
    > > 2.create a bitmap using the width and height of the text in the file
    > > 3.draw the text into the dc using the RichCtrls drawing routines.

    >
    > How can I draw the text (and pictures) in the dc? I don't understand
    > what you mean by 'the RichCtrls drawing routines'.
    >
    >
    > Sven




  7. Re: Print RTF spanning multiple pages

    helpful hint at logical application!

    PP wrote in message
    news:1cd4466a.0311040652.7175c69@posting.google.co m...
    > Hi,
    >
    > My application uses a RTF file to report the results of an execution.
    > This report file can be printed out automatically or saved for future
    > purposes. The content of the RTF report file is very diverse: text in
    > different fonts and colors, pictures, tables, ... When I create the
    > RTF file I set its page width to the maximum (up to 5 times a normal
    > A4 width) so that ever large objects (tables or pictures) can be
    > displayed correctly.
    >
    > I run into problems when the content I want to print out is wider than
    > one physical page: a long line of text gets 'word wrapped' to the next
    > line(s) instead of continuing, a picture gets cut off when its hits
    > the border of the page.
    >
    > I would like to have the RTF print out like an excel sheet does: when
    > the content is too wide, excel prints another page next to the
    > previous one to show the content that could not be display on the
    > first page. That way there are not only pages from top to bottom but
    > also from left to right.
    >
    > A possible solution would be to import the RTF in excel to print it
    > out, but excel has a stupid limitation to show only the first page (in
    > the vertical dimension) and (I think) there's no way to work around
    > that.
    >
    > Does anyone know how to print out an RTF file in the two dimensions?
    > Perhaps some control or a piece of code (C, C#, VB) ...
    >
    >
    > Thanks,
    > Sven




+ Reply to Thread