Solved

rtf: page breaks 2

Posted on 2011-02-22
2
260 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
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
Comment Utility

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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now