You are here:

C++/RTF to PDF Convertor

Advertisement


Question
Dear Mr.McAdrell,
I hope you are doing fine and well, i extend
my best wishes for you.

I am currently a second year student of Computer
Sciences. Just taken a course in C/C++. We have
been assigned with a real world problem i.e.

"RTF to PDF Convertor"

I am currently very naive of real world problems.
Mostly, we have handled very basic assignments
like Hospital Management System. Now this problem
is testing my real wits. Actually, i wanted
to know a step by step approach of how to solve
this particular problem. I will be using Visual
C compiler for developing this application. I
just want a slight idea, from where to start
very basic approach and then how to proceed
step by step. If u can guide me out in this matter, i would be highly obliged.

If, it was your project, what first step you
might have done and like you were a beginning
programmer for such a problem. I look forward
to hear from you soon.

Sincerely,
Zenaits

Answer
Well, if it were me I would first try to find out if there were already some things I could use to reduce the size of the task - libraries, components, etc. that I could use in my code to help with the two main tasks involved in such a converter: having the code make sense of the source format - RTF in this case and writing out in the target format - PDF in this case.

I would also look into the two formats to get at least an overview of their structure - as even with help to load and save the file type in question in the middle there still need to be a mapping from one to the other.

I your case you may or may not be allowed to use other software in your solution - that detail will be in the assignment or can be clarified by those who set the problem.

If you cannot use other software to help out then you will need a detailed understanding of both RTF and PDF file formats. Once you have these you can decide the structure of the solution. For example, do you load the whole RTF document into memory as some intermediate set of structures and then use these to convert to PDF on output or can you build the PDF file piece by piece from reading the RTF document in a bit at a time? Or would you use something in between? Only an understanding of both formats can answer such questions.

I would hope that the final code would allow a good abstraction of the two documents so you might be able to say things like:

       pdfDoc.SetTitle( rtfDoc.GetTitle() );

if such operations are relevant to both document types. I have assumed here that you will be using C++ - though you only mentioned Visual C - the product as far as I am aware has always been Microsoft Visual C++ so I took this to be what you meant. Also be aware that the older (pre version 7 a.k.a. .NET editions) have many bugs and non-standard requirements as far as compliance with ANSI/ISO standard C++.

So to recap my first action would be to look for more information on the problem and possible solutions. To achieve this I would turn to the Internet - starting at my preferred search engine, which for me would be Google (http://www.google.co.uk/). At the search site I would spend quite some time devising queries to look for information on RTF and PDF document formats and any (hopefully open source and freely useable and downloadable) software that may be of help. I might also check my local sources for any information - libraries, online documentation etc., check out a book store and actually buy a book or two.... At one time Microsoft supported RTF format - in fact I think MS Word at one point used it or an extension of it for its .doc file format - so maybe my local MSDN library would have some useful articles - of course the MSDN library is also publicly online on the Internet at http://www.msdn.microsoft.com/.


Hope this sets you on the path..have fun.  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Ralph McArdell

Expertise

I am a software developer with more than 15 years C++ experience and over 25 years experience developing a wide variety of applications for Windows NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C (although I do not write just-C much if at all these days so maybe ask in the C section about purely C matters), software development and many platform specific and system development problems.

Experience

My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines. Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is). When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD. My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets including system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes. I have an interest in the development of the C++ core language and libraries and try to keep up with at least some of the papers on the ISO C++ Standard Committee site at http://www.open-std.org/jtc1/sc22/wg21/.

Education/Credentials

©2016 About.com. All rights reserved.