Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 7, 2007, 08:48 AM   #1
ehayut
macrumors member
 
Join Date: Jun 2005
Converting Word docs, XML, and HTML to PDF

Hi,

I am developing a cross platform (Windows+Mac) desktop app using C++. I'm looking for a tool to programmatically convert any sort of document (.doc, .txt, .rtf, .xml, .html) to a PDF format.

I have found many tools, but they are almost all Windows only. Does anybody know of any tool/API that will allow me to do this cross platform?
ehayut is offline   0 Reply With Quote
Old Aug 7, 2007, 09:45 AM   #2
jellomizer
macrumors 6502
 
Join Date: Sep 2006
Location: Upstate NY
OS X and PDF.

Well remember that OS X has PDF Support build in. I am sure you can make an Apple Script that opens Office (or text edit with some sucess), or Safari then have it do a print and there is a print option to PDF. I know you may be looking for a more direct C++ using some shared libs but the best way may just make an apple script (or have your C++ program generate the apple script) and execute it. C++ is not a good language for creating cross platform application. Finding cross platform libaries for converting these files to PDF will be very difficult because espectially .DOC format requires a fare amount of work to aproximate and Microsoft isn't helpful in releasing the specs. .xml and .html too even with the full specs are considered hard to render, just becasue of all the specs that need to be followed. The best you can probably do is use some pre-procesor definations and part of the make file say the code is either for OS X or Windows and do the different methods for both of them. Remember these are pre-processor definanitions so it essentionally doesn't compile the code if it isn't in the #IFDEF .
__________________
17" Core 2 Duo MacBook Pro
3GB of RAM, 100GB 7200 RPM, Glossy

Last edited by jellomizer; Aug 7, 2007 at 09:56 AM. Reason: Didn't fully answer the question
jellomizer is offline   0 Reply With Quote
Old Aug 7, 2007, 09:47 AM   #3
netdog
macrumors 603
 
netdog's Avatar
 
Join Date: Feb 2006
Location: London
Yes, you'll find it in the PRINT function of OS X. Print, PDF, Save as PDF. It works flawlessly, and surely there is a way to access this function in an automated way.
__________________
We don't see the world as it is. We see it as we are. -Anais Nin
Classical Homeopath and Naturopathic Doctor in London
netdog is offline   0 Reply With Quote
Old Aug 7, 2007, 09:59 AM   #4
ehayut
Thread Starter
macrumors member
 
Join Date: Jun 2005
Thanks for the responses, but I need a way to do this in a way such that it will work in both Windows and on a Mac without having to write platform specific code. I know that a lot of the tools out there need a copy of Word installed, which is fine by me. The tool doesn' have to ahve reverse engineered the .doc format :P

Any other suggestions?

Thanks again.
ehayut is offline   0 Reply With Quote
Old Aug 7, 2007, 10:18 AM   #5
jellomizer
macrumors 6502
 
Join Date: Sep 2006
Location: Upstate NY
[QUOTE=ehayut;4011461]but I need a way to do this in a way such that it will work in both Windows and on a Mac without having to write platform specific code.[QUOTE]

That will be the hard part... OS X and Windows are actually very different OS's while a lot of code usually the logic can be cross compatible the easiest way of doing what you need to be done can't really be by cross platform programming, You will need to have a Windows way and an OS X way. The time that it will take you to do it both ways will be probably less then searching for a solution that will work both ways, wich may or may not work as well. If you do find a cross platform library it will probably just do the same thing having two different platform independant code segments and will choose wich segment to compile depending on what OS you are compiling on. This sounds like an ambishious project and I know you want to do it the best way idologically, and I can commend the effort. But sometimes you need to suck it up and and do it the platform independent route. You can still have both options in your code base and depending on the compiler you compile one version of you convert module vs the other one. It really isn't all that bad and it is done more often then not on cross platform apps.
__________________
17" Core 2 Duo MacBook Pro
3GB of RAM, 100GB 7200 RPM, Glossy

Last edited by jellomizer; Aug 7, 2007 at 10:18 AM. Reason: lost my quote
jellomizer is offline   0 Reply With Quote
Old Aug 7, 2007, 10:47 AM   #6
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
You will probably want to write a separate Cocoa CLI app for the Mac that does the conversion, and another for Windows. Here's a tutorial to get you started: Create a PDF

Combine that with an NSTextView that displays an NSAttributedString (which can be made from RTF, Word, HTML, etc), should be pretty simple to create if you're familiar with Cocoa.

Edit: if you don't want to go down the Cocoa road, check out this article, which has sample C code:
PDF Document Creation, Viewing, and Transforming

Last edited by kainjow; Aug 7, 2007 at 10:56 AM.
kainjow is offline   0 Reply With Quote
Old Aug 7, 2007, 12:25 PM   #7
ehayut
Thread Starter
macrumors member
 
Join Date: Jun 2005
Thank you very much, you guys have been very helpful. I will look into all your recommendations.
ehayut is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Office Docs: Word Processor & Reader for Microsoft Office - PDF Maker umerahmed iPad Apps 0 Mar 16, 2014 06:40 AM
Sale for Blog Docs - Google Docs™ HTML Editor for WordPress Blogger Tumblr & Email Stevesmith001 iPad Apps 0 Mar 6, 2013 01:31 AM

Forum Jump

All times are GMT -5. The time now is 01:23 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC