Using Latex in a C++ Program - c++

I want to write a program that allows me to type in plain text and LaTex code into a text field and displays in real time that text parsed with LaTex, essentially how the preview panel works in stackexchange. For example, as I'm typing this, $this code$ would be displayed in typeset format (if I was on mathexchange) in real type as I'd be typing this message. Is there a libarary I can use for C++ that would let me write a program like that? Where should I begin? Thanks for your time! (Oh, I also plan on developing this through QT).

Related

how to support output paging in C++ application

Our application can generate some fairly long report files interactively. We use C++ to generate all the output, but redirected through a TCL console and TCL channel so we can take advantage of output logging etc.
Is there any common way to support paging of output in C++. I've casted around but can't find anything.
Best
Sam
OK, so the situation is that you're writing to a Tcl_Channel that a Tcl interpreter is also writing to. That should work. The simplest way to put paging on top of that is to make that channel be one of the standard channels (I'd pick stdout) and feed the whole lot through a pager program like more or less. That'll only take you a few seconds to get working.
Otherwise, it's possible to write a channel in Tcl 8.5 using just Tcl code; that's what a reflected channel is (that's the Tcl 8.6 documentation, but it works the same way in 8.5). However, using that to do a pager is going to be quite a lot of work; channels work with bytes not characters. It's probably also possible to do it using a stacked channel transformation (8.6 only).
However, if sending the output to a Tk text widget is acceptable (I know it isn't precisely what you asked for…) there's already a package in Tcllib for it.
package require Tk
package require tcl::chan::textwindow
pack [text .t]
set channel [tcl::chan::textwindow .t]
puts $channel "This is a simple test."
That (write-only) channel will work fine if you pass it to your C++ code to use. (You can inspect the source to see how it is done if you wish; the code is pretty short.)

Printing of HTML markup with C++

I was curious if I can embed printing of HTML markup in my C++ application? Here's what I need:
Ability to specify which printer to print to.
Ability to change paper size.
Ability to specify margins/gutter, etc.
Ability to let end-user preview the result.
It would be easier to virtually print the HTML page to a PDF file using wkHTMLtoPDF C++ Library, and then print it.
Pros:
It allows you to keep a draft copy for future use.
Cons:
It's not a print-HTML-directly library
Have a look at this library: http://www.terrainformatica.com/htmlayout/ . It does everything you need, assuming you want to print the rendered html, and not syntax-highlighted html source code, which is not entirely clear from your question - but
MFC has a CHtmlView class that is part of their Document/View architecture. Hence, you can create a rather simple MDI "Web Browser" in MFC pretty easily.

Converting HTML file to PDF using Win32/MFC

As part of my application, my client has requested that I include an automated e-mailing system. As part of this system, I generate HTML code and use automation to send it via. Outlook.
However, they also require a PDF copy of the HTML document to be sent as an attachment. My initial attempts involved using libHaru, which proved difficult to use efficiently, as I was required to create the PDF document from scratch, which required computation of the position of each of the lines in a table, and positioning of all the text, etc.
I was wondering if there would be a way to programmatically convert HTML code (or an HTML file if need be) into a PDF document either by using Win32/MFC itself or an external library.
Thanks in advance!
EDIT: Just to clarify, I am looking for solutions which minimize external dependencies.
You should evaluate this utility wkhtmltopdf:
http://code.google.com/p/wkhtmltopdf/
You can call it from the command line without the need to run a setup.
I use it generating my output documents as html then cal a ShellExecute(...) to convert it to PDF. It's great!
Inside uses webkit + qt. So compability with modern HTML is OK.
Hope it helps.
I'd take a look at PDF Creator, which can be used as a COM object (that acts pretty much like a printer). I haven't used it to print HTML, so I'm not sure, but my guess is that you'll probably end up having to instantiate a web browser control to render the HTML, and then feed it from there to the PDF control.
Some possible answers are in this thread:
C++ Library to Convert HTML to PDF?
Not sure if they will satisfy your particular requirements, but these might at least get you started.
Edit:
Some other possible options here.
Not MFC but you can try QtWebKit. It can render and export HTML to PDF, PNG, JPEG

Office Template - Embedded VB Script Inactive/Unspported?

First off, this might be the simplest questions on this site depending on the answer.
Question: Is Embedded VB scripts supported in Office Word templates (.dot/.dotx)?
If not, thank you!
If it is, why is this not working:
http://postimage.org/image/2uubobv38/
It works flawlessly in a .doc format but not when i try to save it as a template.
I'm running Office 2007 but 2003 doesn't work either, is there something special you need to enable for using embedded scripts in a .dot file?
I don't know if this is the proper forum for questions like this, but i really don't know anywhere else to turn regarding programming in general so.. help?
Ok so after some logical debugging (read: days), i found out that it IS supported, just not in the "traditional" way of thinking.
In a normal document, you apparently use the Open() function to load things when opening the document, because that's what you do, you open the document.
When using embedded scripts in a .dot file, you're not opening the file.. you are creating a new instance of the .dot file so the function you should be using is New():
Private Sub Document_New()
UserForm1.Show
End Sub
This should show you form from "opening" a .dot file.

Convert .odt .doc .ods files to .txt files

I want to convert all the .odt .doc .xls .pdf files to .txt files.
I want to convert these files to text files using a shell script or a perl script
There's a program for odt files and alikes:
odt2txt - avaliable in repos.
$ unoconv --format=txt document1.odt
Should produce document1.txt.
OpenOffice has a built-in document converter capable of handling a bunch of formats- take a look at unoconv: http://dag.wieers.com/home-made/unoconv/
That being said, I have had some troubles getting that to work in the past- If you're having trouble, take a look at similar programs for AbiWord (another open source word processor).
For word documents, you can try antiword, at least on linux. It's a command line utility that takes a word document as an argument, and spits out the text from that document (as best as it can figure) to Standard Output. Maybe you can specify an ouput file too. I can't remember the details of how it works. I haven't used it in a while. Not sure if it can handle OO documents.
It's certainly possible to do this, though there is something strange and impenetrable about the OO project and its documentation that makes things like this hard to research and follow. However, OO has the capability to convert all of those types, not just the OO native ones, and it can do it via two different forms of automatic control.
These are the two general approaches.
You can start OO and tell it to execute a macro which does this job for you for a given file. You then just have to write the macro and a script to loop over your files. The syntax is something like
$ oowriter -headless filename macro://dir/Standard.Module1.sMySub
The other thing OO has is a network API. This is based on something called UNO.
$ oowriter -accept=accept-string
Notifies the OpenOffice.org software that upon the creation of
"UNO Acceptor Threads", a "UNO Accept String" will be used.
You will need some sort of client library. I think they have one for Python at least. Using this technology a Python program or some other scripting language with an OO client library could drive the program and convert all the files. Since OO reads MSO, it should be able to do all of them.
Open the file in LibreOffice. Click on "File", "Save-as" scroll down to find the text option. Click that and it will be saved as a text file.
FYI, I had an *.ODT file that was 339.2 KB in size. When I save-as text the size of the file shrunk to ONLY 5.0 KB. Another reason for saving your files as text files.
For the Microsoft formats, look into the wvWare tools.
Open .ods file normally in libre office
Highlight text to be converted
Open a terminal
Run vi
Press "i" to get insert mode
Press ctrl-shift-v
Done!
Need some formatting?
Save the file as
Get out of vi
Run:
$cat | column >filename2
This worked in opensuse running KDE
Substitute "kwrite" for "vi", if you want