RTF files
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
RTF files
I am wondering if the following is possible via FWH ????
I would like to open an RTF file, search for some text (ie: <DAT:NAME>) and replace the found text with a filed from a DBF file (ie: MyDBF->Name ).
After the text is changed I would like to save the RTF as a PDF file.
I would like to be able to do all of this with nothing displayed on the screen.
Is this possible?
I would like to open an RTF file, search for some text (ie: <DAT:NAME>) and replace the found text with a filed from a DBF file (ie: MyDBF->Name ).
After the text is changed I would like to save the RTF as a PDF file.
I would like to be able to do all of this with nothing displayed on the screen.
Is this possible?
Thanks,
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Re: RTF files
Never mind.
My original files were created in Word then saved as RTF files. They lose some formatting so I can't go with RTF.
Is there any way to do the same type of thing with Word files, without having Word installed?
My original files were created in Word then saved as RTF files. They lose some formatting so I can't go with RTF.
Is there any way to do the same type of thing with Word files, without having Word installed?
Thanks,
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: RTF files
Jeff,
I just tried this:
word2pdf.prg
https://msdn.microsoft.com/en-us/librar ... e.12).aspx
but it does not work as expected. Also I guess that the user must have Word installed
Also I realized that a docx document is a renamed zip file. So maybe you could replace text inside it.
I just tried this:
word2pdf.prg
Code: Select all
#include "FiveWin.ch"
function Main()
local oWord := CreateObject( "Word.Application" )
local oDoc := oWord:Documents:Open( "c:\document.docx" )
oDoc:Activate()
oDoc:SaveAs2( "c:\document.pdf", 17 )
oDoc:Close()
return nil
but it does not work as expected. Also I guess that the user must have Word installed
Also I realized that a docx document is a renamed zip file. So maybe you could replace text inside it.
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Re: RTF files
Hi Antonio,
I am able to do exactly what I need if I have MS-Word installed.
The problem I run into is that Word does not really like being run from a program that is running as a service.
It works "most" of the time but every now and then Word get hung up and stalls my program.
I was hoping to do this somehow without needing Word
I am able to do exactly what I need if I have MS-Word installed.
The problem I run into is that Word does not really like being run from a program that is running as a service.
It works "most" of the time but every now and then Word get hung up and stalls my program.
I was hoping to do this somehow without needing Word
Thanks,
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Re: RTF files
Jeff,
a docx is a zip file. Open the file and you find document.xml.
You can change document.xml and then pack all files and rename it back to docx.
Best regards,
Otto
http://forums.fivetechsupport.com/viewt ... ocx#p69231
a docx is a zip file. Open the file and you find document.xml.
You can change document.xml and then pack all files and rename it back to docx.
Best regards,
Otto
http://forums.fivetechsupport.com/viewt ... ocx#p69231
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Re: RTF files
Thanks Otto ... one step closer.
This will work for replacing text but I also need to be able to replace one of my "tokens" (ie: <DAT:SIG>) with an image.
Would you know how I could do this?
This will work for replacing text but I also need to be able to replace one of my "tokens" (ie: <DAT:SIG>) with an image.
Would you know how I could do this?
Thanks,
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Re: RTF files
Jeff,
please look into the folder:
word\media
Best regards,
Otto
please look into the folder:
word\media
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Re: RTF files
Hi Otto,
I saw that the images are in that folder. I guess what I need to know is how (or where) would I tell word to use the image so that it goes in place of my text <DAT:SIG> ?
I saw that the images are in that folder. I guess what I need to know is how (or where) would I tell word to use the image so that it goes in place of my text <DAT:SIG> ?
Thanks,
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Re: RTF files
Jeff,
use a dummy jpg in your template.
Then you can overwrite the jpg in media folder.
Best regards,
Otto
use a dummy jpg in your template.
Then you can overwrite the jpg in media folder.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Re: RTF files
Otto you are a genius
That is an excellent idea.
Thanks.
That is an excellent idea.
Thanks.
Thanks,
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Jeff Barnes
(FWH 12.01, xHarbour 1.2.1, Bcc582)
Re: RTF files
The OLE-error, could it be that a wrong Office version is installed?
Not all versions have OLE included (student versions, private versions, etc.).
You need to have a professional Office version to be able to use OLE.
Not all versions have OLE included (student versions, private versions, etc.).
You need to have a professional Office version to be able to use OLE.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Re: RTF files
In new version Fwh 16.11 implemented:
Menu
- File - Open
- File - To Pdf
TESTRTF5.PRG in folder samples
* RICHEDIT5
- New METHOD SaveToPDF( cName, cFile, lView )
cName := <Optional - Name of report - Not used yet>
cFile := File of PDF file
lView := View PDF file, if .T.
You do not need to have WORD installed
Menu
- File - Open
- File - To Pdf
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.