bb.donnay-software.com

Donnay Software Web Forums
It is currently Fri Aug 23, 2019 8:31 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: RTF to PDF
PostPosted: Thu Mar 09, 2017 6:14 pm 
Offline
Site Admin
User avatar

Joined: Wed Jan 27, 2010 6:58 pm
Posts: 3958
Location: Boise, Idaho USA
Here is a handy little program that converts an RTF file to a PDF file.

It uses the XbpRtf() class and the Bullzip PDF Printer driver.

Code:
#INCLUDE "dcdialog.CH"
#Pragma Library("ascom10.lib")

FUNCTION Main( cFileName )

LOCAL oRtf, cMemo := '', GetList[0], GetOptions, oPrinter, oBullZip, ;
      cOutFile, nChoice := 1

IF Empty(cFileName)
  cFileName := DC_PopFile(,,'*.rtf')
ELSEIF Empty(DC_Path(cFileName))
  cFileName := DC_CurPath() + '\' + cFileName
ENDIF

IF Empty(cFileName)
  QUIT
ENDIF

cOutFile := Strtran(cFileName,'.rtf','.Pdf')
cOutFile := Strtran(cOutFile,'.Rtf','.Pdf')
cOutFile := Strtran(cOutFile,'.RTF','.Pdf')

oBullZip := ActiveXObject():create('Bullzip.PDFPrinterSettings')
oBullZip:SetValue('Output',cOutFile)
oBullZip:SetValue('ShowSaveAs','never')
oBullZip:SetValue('ShowSettings','never')
oBullZip:SetValue('ShowPdf','no')
oBullZip:SetValue('ConfirmOverwrite','no')
oBullZip:SetValue('ShowProgressFinished','no')
oBullZip:SetValue('ShowProgress','no')
oBullZip:WriteSettings()

oPrinter := XbpPrinter():new()
oPrinter:create("Bullzip PDF Printer")
oPrinter:setPrintFile(cOutFile)

@ 0,0 DCRTF ;
   OBJECT oRTF ;
   SIZE 80,20 ;
   VAR cMemo ;
   EVAL {|o|o:loadFile(cFileName), ;
            o:Print(oPrinter)}

DCGETOPTIONS ;
   HIDE ;
   RESIZE

DCREAD GUI FIT TITLE 'RTF to PDF' ;
   EXIT ;
   OPTIONS GetOptions

DCMSGBOX 'File Created: ' + cOutFile ;
   BUTTONS {'View PDF File','Exit'} CHOICE @nChoice

IF nChoice == 1
  DC_SpawnUrl(cOutFile)
ENDIF

RETURN nil

* --------

PROC appsys ; RETURN

_________________
The eXpress train is coming - and it has more cars.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group