Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-01

Converting .doc and/or .html to .pdf

12 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andreas Schneider
to Marcos Douglas
Marcos Douglas wrote
Hi, There are libs, in Pascal, to convert .doc and/or .html files to .pdf?

I don't think so, but I would suggest to use a headless OpenOffice.org/LibreOffice for the conversion. Using the Pascal UNO Bridge you may even be able to control it from a Pascal application, but for a simple conversion it's probably a lot easier to just invoke it via commandline.

Best Regards, Andreas

Reply by email

Marcos Douglas
to Andreas Schneider
Andreas Schneider wrote 9 lines
On Saturday, January 15, 2011 22:18 Marcos Douglas wrote: > Hi, > There are libs, in Pascal,  to convert .doc and/or .html files to .pdf? I   don't   think   so,   but  I  would  suggest  to  use  a  headless OpenOffice.org/LibreOffice  for  the  conversion. Using the Pascal UNO Bridge  you  may even be able to control it from a Pascal application, but  for a simple conversion it's probably a lot easier to just invoke it via commandline.

You're right. The command line is more simple.
Thanks for the tip, I will try this.

Marcos Douglas

Reply by email

Marcos Douglas
to Marcos Douglas
Marcos Douglas wrote 13 lines
On Sat, Jan 15, 2011 at 7:39 PM, Andreas Schneider wrote: > On Saturday, January 15, 2011 22:18 Marcos Douglas wrote: >> Hi, >> There are libs, in Pascal,  to convert .doc and/or .html files to .pdf? > > I   don't   think   so,   but  I  would  suggest  to  use  a  headless > OpenOffice.org/LibreOffice  for  the  conversion. Using the Pascal UNO > Bridge  you  may even be able to control it from a Pascal application, > but  for a simple conversion it's probably a lot easier to just invoke > it via commandline. You're right. The command line is more simple. Thanks for the tip, I will try this.

I have not found
I'm looking in http://api.openoffice.org/
Is it mandatory use UNO bindings?

I want do the same of this project http://html2pdf.fr/

Marcos Douglas

Reply by email

Felipe Monteiro de Carvalho
to Marcos Douglas

Another solution is that you could start a generic library for handling formatted text documents. It will certainly be harder, and take more time, but the end result will be much better and it won't require having OpenOffice installed (a rather huge thing to have as a dependency).

We already have a spreadsheet library:
http://wiki.lazarus.freepascal.org/FPSpreadsheet

Something similar could be done for handling the class of formatted documents, like pdf, doc, html, etc.

FPVectorial has support for PDF reading, but only from a vectorial drawing point of view, nevertheless it's code and documentation which explain the PDF format could be reused. I actually have documentation in portuguese about the PDF format.
http://wiki.lazarus.freepascal.org/fpvectorial

Felipe Monteiro de Carvalho

Reply by email

Marcos Douglas
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 17 lines
Another solution is that you could start a generic library for handling formatted text documents. It will certainly be harder, and take more time, but the end result will be much better and it won't require having OpenOffice installed (a rather huge thing to have as a dependency). We already have a spreadsheet library: http://wiki.lazarus.freepascal.org/FPSpreadsheet Something similar could be done for handling the class of formatted documents, like pdf, doc, html, etc. FPVectorial has support for PDF reading, but only from a vectorial drawing point of view, nevertheless it's code and documentation which explain the PDF format could be reused. I actually have documentation in portuguese about the PDF format. http://wiki.lazarus.freepascal.org/fpvectorial

Yes, that is a better solution for the future... unfortunately I have not time so much to make this software. The plataform is Windows and old ASP to make sites. I have to make a component to ASP call to make this convert, HTML to PDF.

If exists a C lib, eg, facilitate my work.

Marcos Douglas

Reply by email

Andreas Schneider
to Marcos Douglas: I have not found I'm looking in http://api.openoffice.org/ Is it mandatory use UNO…
Marcos Douglas wrote
> You're right. The command line is more simple. > Thanks for the tip, I will try this. I have not found

Since you also mentioned that you need to access it from ASP, I guess that one might offer you the most flexibility:
http://www.artofsolving.com/opensource/jodconverter

... because you can run it as webservice. Or you can simply invoke it from commandline.

Best Regards, Andreas

Reply by email

Marcos Douglas
to Andreas Schneider
Andreas Schneider wrote 12 lines
On Friday, January 28, 2011 15:52 Marcos Douglas wrote: >> You're right. The command line is more simple. >> Thanks for the tip, I will try this. > I have not found Since  you also mentioned that you need to access it from ASP, I guess that one might offer you the most flexibility: http://www.artofsolving.com/opensource/jodconverter ...  because you can run it as webservice. Or you can simply invoke it from commandline.

Yes, I think is easy to use. Thanks, I will see on next Monday, at work.

Marcos Douglas

Reply by email

Bo Berglund
to Andreas Schneider: Since you also mentioned that you need to access it from ASP, I guess that one might…
Andreas Schneider wrote 12 lines
On Friday, January 28, 2011 15:52 Marcos Douglas wrote: >> You're right. The command line is more simple. >> Thanks for the tip, I will try this. > I have not found Since you also mentioned that you need to access it from ASP, I guess that one might offer you the most flexibility: http://www.artofsolving.com/opensource/jodconverter ... because you can run it as webservice. Or you can simply invoke it from commandline.

Interesting, I have been looking for some way to convert a large number of Word documents to PDF in some automated way without using MS Office, because as far as I have seen it would have to be done manually by printing to a PDF printer.

The company I work for has a system for writing up purchase specifications for all the parts we use as standardized documents in Word format. There are literally thousands of these.

The problem is that in order to read them one must have an instance of MSOffice installed and it sometimes takes a long time to open each document too. So I have been on the lookout for some way to implement a program for converting these to PDF.
As an example all our drawings are stored for access by production in PDF format, which is very simple to use (and quick if one refrains from using the Adobe reader).

And now this thread appears here that is very similar to what I need. If a Lazarus/FPC implementation is created, possibly using the OpenOffice hook described here, I would be very much interested too!

The link above goes in the end to a download of *compiled* java code so it is not that good for me. An FPC implementation would be really useful though.

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund
Andreas Schneider wrote 18 lines
On Sunday, January 30, 2011 09:46 Bo Berglund wrote: > The link above goes in the end to a download of *compiled* java code > so it is not that good for me. An FPC implementation would be really > useful though. The source code of jodconverter is available, as you can see on that very page I linked (on the bottom ;-)). Automating OOo with FPC is not completely impossible, but far from trivial. Even if you have the necessary code, you still have to setup the ABI between OOos C++ interface and FPC. That's essentially what the current Pascal UNO Bridge does. But as I said: far from trivial. That's one of the reasons I did all my OpenOffice.org extensions in Java ;-) -- Best Regards, Andreas

Right, after I wrote my message I realized I had a WinXP virtual machine with OpenOffice 3.2 installed, so I downloaded the converter and tested it using the manual command line commands.

It worked OK to convert a 2-page test document. :-)

I have a question in this context, tha you might answer: In the description you are directed to starting OpenOffice.org in headless mode as a socket server. Then the Java application can connect to it and make the conversion.
But what is NOT specified is how you get rid of the headless running OpenOffice application...
I don't want it running after I am done with my conversion. Is there a way except through TaskManager (provided it only loads the two files exe and bin)???

A will heed your advice concerning the coding and not dive in due to the complexity. Will instead try to utilize the java function via a TProcess object such that I can manage the files that are to be converted.
*That* shouldn't be too difficult to do in Lazarus/FPC...

Bo Berglund Developer in Sweden

Reply by email

José Mejuto
to Bo Berglund: On Fri, 28 Jan 2011 22:27:17 +0100, Andreas Schneider Interesting, I have been looking…

Hello Bo,

Sunday, January 30, 2011, 9:46:22 AM, you wrote:

BB> The problem is that in order to read them one must have an instance of BB> MSOffice installed and it sometimes takes a long time to open each BB> document too. So I have been on the lookout for some way to implement BB> a program for converting these to PDF.
BB> As an example all our drawings are stored for access by production in BB> PDF format, which is very simple to use (and quick if one refrains BB> from using the Adobe reader).
BB> And now this thread appears here that is very similar to what I need. BB> If a Lazarus/FPC implementation is created, possibly using the BB> OpenOffice hook described here, I would be very much interested too!

I had done this in Delphi in the past years using the Adobe Reader 5 OCX and a Virtual PDF Printer. Maybe I have the code somewhere.

Best regards, José

Reply by email

José Mejuto
to Bo Berglund: On Fri, 28 Jan 2011 22:27:17 +0100, Andreas Schneider Interesting, I have been looking…

Hello Bo,

Sunday, January 30, 2011, 9:46:22 AM, you wrote:

BB> And now this thread appears here that is very similar to what I need. BB> If a Lazarus/FPC implementation is created, possibly using the BB> OpenOffice hook described here, I would be very much interested too!

Please, forget my last post... I completly missunderstood the idea. My apologizes.

Best regards, José

Reply by email