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

  • SEARCH
  • Home
  • 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 7977323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:09:52+00:00 2026-06-04T09:09:52+00:00

Here there are an example of saving an OpenOffice file to PDF. I’m using

  • 0

Here there are an example of saving an OpenOffice file to PDF. I’m using similar code to save Calc files to PDF. (It’s enough to change the property writer_pdf_Export to calc_pdf_Export.)

Unfortunately, the code doesn’t take into account the print area defined in the original file.

How can I do that?

  • 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-06-04T09:09:53+00:00Added an answer on June 4, 2026 at 9:09 am

    Extending my previous code (which is not as clean as it could be) I would try something like this (note I haven’t tested it yet). The third parameter specifies the exported range as TRect variable:

    procedure ExportCalcRangeToPDF(const ASourceFileURL, ATargetFileURL: string;
      ASheetIndex: Integer; ARange: TRect);
    var
      CellRange: Variant;
      StarOffice: Variant;
      StarDesktop: Variant;
      StarDocument: Variant;
      FilterParams: Variant;
      ExportParams: Variant;
      ExportObject: Variant;
    
      function CreateProperty(const AName: AnsiString; const 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);
      CellRange := StarDocument.Sheets.getByIndex(ASheetIndex).getCellRangeByPosition(
        ARange.Left, ARange.Top, ARange.Right, ARange.Bottom);
    
      ExportParams := VarArrayCreate([0, 0], varVariant);
      ExportParams[0] := CreateProperty('Selection', CellRange);
    
      ExportObject := StarOffice.Bridge_GetValueObject;
      ExportObject.Set('[]com.sun.star.beans.PropertyValue', ExportParams);
    
      FilterParams := VarArrayCreate([0, 1], varVariant);
      FilterParams[0] := CreateProperty('FilterName', AnsiString('calc_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
      ExportCalcRangeToPDF(
        'file:///C:/SourceFile.ods',
        'file:///C:/TargetFile.pdf',
        0,
        Rect(1, 1, 2, 2)
      );
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to execute internal code via reflection? Here is an example
I couldn't find a more descriptive title, but here there is an example: import
I had a similar question answered Here There is a slight twist to the
i'm trying wmd editor over ajax. here there is the bugged code wdm code
Rails noob here. I have a rails application with (in this example) three tables.
Here and there people keep talking about memory leaks which occur due unreleased event
Simple question here: is there any way to convert from a jagged array to
I see there is a question here but there is no definite answer. Has
a simple question here Is there a way to change the text click here
I apologize to move it from here as there was some confusion and thanks

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.