Universal Document Converter

This forum is for posting of useful information
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Universal Document Converter

#1 Post by rdonnay »

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.

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
The eXpress train is coming - and it has more cars.

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Universal Document Converter

#2 Post by skiman »

Hi,

Yes, if Word or Office is available, this works fine.

We use oSheet:ExportAsFixedFormat to create PDF files from Excell sheets. This way we create nice product catalogs with hundreds of pages.
Best regards,

Chris.
www.aboservice.be

Post Reply