Solved

rtf: page breaks 2

Posted on 2011-02-22
2
268 Views
Last Modified: 2012-05-11
Dear experts,

I have an c++ application that converts .rtf files into another custom format. One of the requirements is to preserve page separation of the text. I understand that .rtf doesn't know about page breaks unless they are inserted explicitly. But still MS Word divides the text into pages based I think on its page settings. Could you please tell me if I can programmatically fetch those settings to use them for calculating where the page breaks should be?
Thanks.
0
Comment
Question by:tantormedia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 34959432

In the absence of specific (manual) page breaks, Word will start to print a new page when the current page is full. This can also be seen on the screen in 'Print Layout' view. However, there is nothing in the Word document file to mark the position; it is recalculated dynamically. This is because the exact position could change according to which print driver and which font versions are being used.

This means that you must use the Word application to find out where it would break the page when printing in the current environment. There are methods in the Word object model to find the position. Here are a couple of examples in Word VBA code.
Sub FindPage23()
    Dim rng As Range
    '(rng.GoTo, though documented, doesn't work)
    Selection.GoTo wdGoToPage, wdGoToAbsolute, 23 
    Set rng = Selection.Range
End Sub

Function GetPageNumber(rng As Range) As Integer
    GetPageNumber = rng.Information(wdActiveEndPageNumber)
End Function

Open in new window

0
 

Author Comment

by:tantormedia
ID: 34961983
Thank you very much. Couldn't you please refer me to some solutions in C++?
I guess all I need is the number of lines on a page based on the current environment.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question