Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6702745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:05:23+00:00 2026-05-26T07:05:23+00:00

Since I just asked this question and got a very useful reply I wonder

  • 0

Since I just asked this question and got a very useful reply I wonder if anyone has already the code for using the documentTopdf routine built in in Open Office for saving odt, doc, docx files to pdf.

Here there is the c# example anyway since having it in Delphi direcly would be great for many users.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:05:23+00:00Added an answer on May 26, 2026 at 7:05 am

    Very similarly 🙂

    Here is the tutorial describing all features used for configuration of the generated document.

    For the following example I chose fit to width magnification, password protection and hidden window controls. The export is done in hidden mode when the OpenOffice window isn’t shown at conversion.

    Note that the following code is again without error handling.

    uses
      ComObj;
    
    procedure OpenOfficeExportToPDF(const ASourceFileURL: string; const ATargetFileURL: string);
    var
      StarOffice: Variant;
      StarDesktop: Variant;
      StarDocument: Variant;
      FilterParams: Variant;
      ExportParams: Variant;
      ExportObject: Variant;
    
      function CreateProperty(const AName: AnsiString; AValue: Variant): Variant;
      begin
        Result := StarOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
        Result.Name := AName;
        Result.Value := AValue;
      end;
    
    begin
      StarOffice := CreateOleObject('com.sun.star.ServiceManager');
      StarDesktop := StarOffice.CreateInstance('com.sun.star.frame.Desktop');
    
      FilterParams := VarArrayCreate([0, 0], varVariant);
      FilterParams[0] := CreateProperty('Hidden', True);
    
      StarDocument := StarDesktop.LoadComponentFromURL(ASourceFileURL, '_blank', 0, FilterParams);
    
      ExportParams := VarArrayCreate([0, 3], varVariant);
      ExportParams[0] := CreateProperty('Magnification', 2);
      ExportParams[1] := CreateProperty('EncryptFile', True);
      ExportParams[2] := CreateProperty('DocumentOpenPassword', AnsiString('StackOverflow'));
      ExportParams[3] := CreateProperty('HideViewerWindowControls', True);
    
      ExportObject := StarOffice.Bridge_GetValueObject;
      ExportObject.Set('[]com.sun.star.beans.PropertyValue', ExportParams);
    
      FilterParams := VarArrayCreate([0, 1], varVariant);
      FilterParams[0] := CreateProperty('FilterName', AnsiString('writer_pdf_Export'));
      FilterParams[1] := CreateProperty('FilterData', ExportObject);
    
      StarDocument.StoreToURL(ATargetFileURL, FilterParams);
    
      StarDocument.Close(True);
      StarDesktop.Terminate;
    
      StarDocument := Unassigned;
      StarDesktop := Unassigned;
      StarOffice := Unassigned;
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      OpenOfficeExportToPDF('file:///C:/SourceFile.odt', 'file:///C:/TargetFile.pdf');
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked already but I would like to solve
I know this question been asked a lot here, but just wondering since ICS
I have previously asked this question and since I already accepted an answer, I
This just saves time. Since I already have a web applciation. I can just
I just started using Sequel in a really small Sinatra app. Since I've got
I got asked this question once and still haven't been able to figure it
I couldn't find this question already being asked on this forum. I am little
I asked this question earlier but I was very vague and a lot of
I just answered this question , which asked why iterating until 10 billion in
I know this question has been asked quite a few times, however, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.