Universal Document Converter
Posted: Wed Feb 16, 2022 5:49 am
Last night, Bobby Drakos and I had to find a quick solution to converting a .RTF document to .PDF.
We are writing a Web interface to the Medallion system so drivers can get a copy of the lease, originally created in .RTF format because it is easiest to merge data with text. They need the document in .PDF format.
Bobby did a search for "document converter" and it took us to https://www.docufreezer.com/news/docume ... h-word-api
In about 10 minutes, I took the sample code and converted it to Xbase++.
It worked perfectly.
We are writing a Web interface to the Medallion system so drivers can get a copy of the lease, originally created in .RTF format because it is easiest to merge data with text. They need the document in .PDF format.
Bobby did a search for "document converter" and it took us to https://www.docufreezer.com/news/docume ... h-word-api
In about 10 minutes, I took the sample code and converted it to Xbase++.
It worked perfectly.
Code: Select all
#pragma Library("ASCOM10.lib")
#pragma Library("DCLIPX.lib")
#DEFINE False .f.
#DEFINE True .t.
FUNCTION Main( cInputFile, cOutputFile )
DocumentConvert( cInputFile, cOutputFile )
RETURN nil
* -----------
PROC appsys ; return
* -----------
FUNCTION DocumentConvert( cInputFile, cOutputFile )
LOCAL app, wdoptions, doc
IF Empty(DC_Path(cInputFile))
cInputFile := DC_CurPath() + '\' + cInputFile
ENDIF
IF Empty(DC_Path(cOutputFile))
cOutputFile := DC_CurPath() + '\' + cOutputFile
ENDIF
App := CreateObject("Word.Application")
app:Visible := False
app:DisplayAlerts := 0
app:FeatureInstall := 0
app:DisplayRecentFiles := False
app:DisplayDocumentInformationPanel := False
app:AutomationSecurity := 3
wdOptions := app:Options
wdOptions:WarnBeforeSavingPrintingSendingMarkup := False
wdOptions:SavePropertiesPrompt := False
wdOptions:DoNotPromptForConvert := True
wdOptions:PromptUpdateStyle := False
wdOptions:ConfirmConversions := False
doc := app:Documents:Open(cInputFile)
doc:ExportAsFixedFormat(cOutputFile, 17)
doc:Saved := True
doc:Close(0)
app:quit()
RETURN nil