#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    4
    Rep Power
    0

    Searching for a component


    I am searching for a component compatible with Delphi 5 to convert single file RTF to PDF.
    Also a component software not installable will do if it is simply distributable, consisting in
    DLL installable by copy, without setup.

    Also an exe which converts from command line will do if it is installable by copy, without setup.

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    397
    Rep Power
    0
    if you have MS Word then it has the capability to save a document as a pdf. Since I don't have Delphi 5 around, you'll need to see which units to add to your code to do OLE automation, in D10Seattle, it is System.Win.ComObj, so that probably means you should add ComObj

    Here's the code
    Code:
    const
       wdExportFormatPDF = 17;
    var
       V: Variant;
       Doc: Variant;
    begin
       V := CreateOleObject('Word.Application');
       try
          V.Visible := False;
          Doc := V.Documents.open('<C:\FileName>.rtf');
          try
            Doc.ExportAsFixedFormat('<C:\NewFileName>.pdf', wdExportFormatPDF);
          finally
             Doc.Close;
          end;
       finally
          V.Quit;
       end;
    end;
    Last edited by majlumbo; April 17th, 2016 at 10:46 AM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    4
    Rep Power
    0

    MS Word could not be installed on PC


    Originally Posted by majlumbo
    if you have MS Word then it has the capability to save a document as a pdf. Since I don't have Delphi 5 around, you'll need to see which units to add to your code to do OLE automation, in D10Seattle, it is System.Win.ComObj, so that probably means you should add ComObj

    Here's the code
    Code:
    const
       wdExportFormatPDF = 17;
    var
       V: Variant;
       Doc: Variant;
    begin
       V := CreateOleObject('Word.Application');
       try
          V.Visible := False;
          Doc := V.Documents.open('<C:\FileName>.rtf');
          try
            Doc.ExportAsFixedFormat('<C:\NewFileName>.pdf', wdExportFormatPDF);
          finally
             Doc.Close;
          end;
       finally
          V.Quit;
       end;
    end;

    MS Word could not be installed on PC
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    397
    Rep Power
    0
    If MS Word isn't possible, then another (non-Delphi) option would be to add a "print" driver that prints to .pdf format. Have a look at CutePDF here.

    or you can possibly use SynPDF, which is free and apparently can be used in D5 - D10Seattle. Find it here, with an example here of how to take a TRichEdit and save it to PDF.
    Last edited by majlumbo; April 18th, 2016 at 10:00 AM.

IMN logo majestic logo threadwatch logo seochat tools logo