Solved

rtf: page breaks 2

Posted on 2011-02-22
2
267 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

Increase your protection from Zero Day threats!

Running two Antivirus' is never a good idea.
Taking advantage of Multiple Security layers on the other hand can often save your hide.
See which top notch security software brands have been proven to happily coexist together.
Reduce your chances of becoming a statistic.

Question has a verified solution.

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

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

738 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