https://bugs.documentfoundation.org/show_bug.cgi?id=166376

--- Comment #1 from Sven Krause <[email protected]> ---
there was a typo in the code, here is the updated version, issue persist.

[code]
using com.sun.star.uno;
using com.sun.star.lang;
using com.sun.star.frame;
using com.sun.star.util;
using com.sun.star.beans;
using com.sun.star.uno.native;
using System.Runtime.InteropServices;
using System.Transactions;
using com.sun.star.ucb;

//Console.WriteLine("Enter a key");
//var input = Console.ReadLine();
string strDoc;
XDesktop desktop = null;
XComponent doc = null;

strDoc = @"file:///f:/test.docx";
// See https://aka.ms/new-console-template for more information
try
{
    XComponentContext context = NativeBootstrap.bootstrap();
    XMultiComponentFactory factory = context.getServiceManager();
    desktop = Desktop.create(context);
    XComponentLoader componentLoader = desktop.query<XComponentLoader>();

    //com.sun.star.beans.PropertyValue[] szEmptyArgs = new
com.sun.star.beans.PropertyValue[0];

    PropertyValue[] loadProps = new PropertyValue[2];
    loadProps[0] = new PropertyValue();
    loadProps[0].Name = "Hidden";
    loadProps[0].Value = new Any(true);

    loadProps[1] = new PropertyValue();
    loadProps[1].Name = "ReadOnly";
    loadProps[1].Value = new Any(true);

    doc = componentLoader.loadComponentFromURL(strDoc, "_blank", 0, loadProps);
    if (doc != null)
    {
        var storable = doc.query<XStorable>();

        List<PropertyValue> filterData = new();
        filterData.Add(new PropertyValue( Name: "PageRange", Handle:-1 , Value:
new Any("2-3"), State: PropertyState.DIRECT_VALUE));
        //filterData.Add(new PropertyValue(Name: "Quality", Handle: -1, Value:
new Any(100L), State: PropertyState.DIRECT_VALUE));

        var props =filterData.ToArray(); ;


        PropertyValue[] saveProps = new PropertyValue[2];
        saveProps[0] = new PropertyValue();
        saveProps[0].Handle = -1;
        saveProps[0].Name = "FilterName";
        saveProps[0].Value = new Any("writer_pdf_Export");

        saveProps[1] = new PropertyValue();
        saveProps[1].Handle = -1;
        saveProps[1].Name = "FilterData";        

        saveProps[1].Value = new Any(props);        

        storable.storeToURL(strDoc +".pdf",saveProps);

        doc.dispose();
        doc = null;
    }
    //desktop.terminate();
}
catch(System.AccessViolationException ex)
{
    Console.WriteLine(ex.Message);
}
catch (ExternalException ex)
{
    Console.WriteLine(ex.Message);
}
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}
finally
{
    doc?.dispose();
    desktop?.terminate();
} 
[/CODE]

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to