Print as PDF - Refresh MediaNameList

Hallo

i create a costum paper size for the Printer "Print As Pdf.pc3" programmatically with c#. I refresh the MediaNameList to with the following code:

var pdfConfig = PlotConfigManager.SetCurrentConfig("Print as PDF.pc3");
pdfConfig.RefreshMediaNameList();

After that i like to set the new paper size in the PlotSettings:


Using (var ps = new PlotSettings(layout.ModelType))
{
ps.CopyFrom(layout);
var psv = PlotSettingsValidator.Current;

psv.SetPlotConfigurationName(ps, pc3FilenameForPDF, "");
psv.SetCanonicalMediaName(ps, papierFormat);
...
...

But that doesn't work. "Teigha.Runtime.Exception: "eInvalidInput" What can i do ?

thanks.