?
Solved

rtf: page breaks 2

Posted on 2011-02-22
2
Medium Priority
?
270 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 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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 …

770 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