RTF to PDF example.

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
kamleshvgujarathi
Posts: 39
Joined: Fri Jan 09 2004
Location: Bombay ( INDIA)
Contact:

RTF to PDF example.

Post by kamleshvgujarathi »

Hello jose,

Can you give a snippet for RTF file to PDF Conversion. ?

:idea:
Kamlesh
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello Kamlesh,

There are two ways to convert RTF files to PDF:

1 - By using the BatchConvert() methods that can convert all RTF files in a given folder to PDF in batch mode

2- By opening each RTF file in Word and printing it to the PDF Printer.

I will add here VB samples for both methods so you can choose the one that best suits you.

Code: Select all

'This sample converts all RTF files in the Temp folder to one pdf file called 'BatchConvert.pdf

'All RTF files are appended to one PDF.  If you remove the Concatenate 'option each RTF file will be converted to a separate pdf

pdf.FileNameOptions = NoPrompt + UseFileName + Concatenate

pdf.DefaultFileName = "c:\Temp\BatchConvert.pdf"

pdf.BatchConvert("c:\Temp\*.rtf")

Code: Select all

'Printing an rtf file while opening it using Word.

'Declarations

'Create a new hidden instance of Word
    Set wordapp = New Word.Application
    
  'Create an instance of a Word document
    Set worddoc = Word.Documents
              
  ' Attach to the existing PDF Printer (Initialize the printer)
    pdf.DriverInit (PrinterName)
                
  ' Set the PDF Printer as Default
    pdf.SetDefaultPrinter

pdf.DefaultFileName = "C:\Temp\Test.pdf"
   
' Set File options.
pdf.FileNameOptionsEx = NoPrompt + UseFileName 

' Open the rtf document
Set worddoc = Documents.Open("C:\Temp\Test.rtf", , , , , , , , , , , True)
    
' Print the rtf document
worddoc.PrintOut ActivePrinter = PrinterName
    
worddoc.Close
        
pdf.FileNameOptions = 0
   


Hope this helps
kamleshvgujarathi
Posts: 39
Joined: Fri Jan 09 2004
Location: Bombay ( INDIA)
Contact:

convert RTF files to PDF

Post by kamleshvgujarathi »

Jone,

Thank you very much your support.

:)
kamlesh@itshastra.com
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Your welcome Kamlesh.

My name in fact is not Jone, it is Joan, it is a shorter name for Joanna.

Have a nice day.
kamleshvgujarathi
Posts: 39
Joined: Fri Jan 09 2004
Location: Bombay ( INDIA)
Contact:

Re: convert RTF files to PDF

Post by kamleshvgujarathi »

kamleshvgujarathi wrote:Joan,

Thank you very much for your support.

:)
kamlesh@itshastra.com
Post Reply