public static void Convert() { string name = "convert.docx"; string format = "xps";//postScript, pcl, dot, dotx, dotm, docm, odt, wordxml, wordml, pdf, doc, docx, rtf, epub, xps, html string password = null; string folder = "input"; string storage = null; string destFilePath = "output/convert_output.xps"; convertApi.Convert(name, format, destFilePath, password, folder, storage); }
public static void Main() { var app = new ConverterDualApp(); app.Run(new Hyperplan.Selenium.Window() { Title = "Temperature Converter - 2", Content = new DockPanel() { Children = new UIElement[] { new ContentControl() { Content = new Button() { Content = "Reset", Margin = ConvertApi.Convert <int, Thickness>(10), Width = 80, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Click = (s, e) => { app.Model = new ConverterModel(); } }, DockPanel_Dock = Dock.Bottom }, new Grid() { RowDefinitions = new RowDefinition[] { new RowDefinition(), new RowDefinition() }, ColumnDefinitions = new ColumnDefinition[] { new ColumnDefinition() }, Children = new UIElement[] { new GroupBox() { Header = "First View", Content = new ConverterView() { _Model_ = new Driver <ConverterModel>(() => app.Model) }.UIElement, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Grid_Row = 0 }, new GroupBox() { Header = "Second View", Content = new ConverterView2() { _Model_ = new Driver <ConverterModel>(() => app.Model) }.UIElement, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Grid_Row = 1 } } } } } }); }
static void Main(string[] args) { string testFile = null; try { // ** Make sure an api key has been entered if (API_KEY == string.Empty) { Console.WriteLine("[ERROR] Please update the sample code and enter the API Key that came with your subscription."); return; } // ** Was a 'file to convert' specified on the command line? if (args.Count() == 0) { Console.WriteLine("[INFO] No file to convert specified, using default file."); testFile = Directory.GetFiles(".", "*.doc")[0]; } else { testFile = args[0]; } // ** Specify the API key associated with your subscription. Configuration.Default.AddApiKey("api_key", API_KEY); // ** Accept all SSL Certificates, this makes life under mono a lot easier. This line is not needed on Windows ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; // ** The service's host name is already set, but for debugging purposes you may want to switch between 'http' and 'https'.' Configuration.Default.ApiClient.RestClient.BaseUrl = new Uri("https://api.muhimbi.com/api"); // ** We are dealing with the ConvertApi, so instantiate the relevant class ConvertApi convertAPI = new ConvertApi(); // ** Read the file we wish to Convert byte[] sourceFile = File.ReadAllBytes(testFile); // ** Fill out the data for the conversion operation. ConvertData inputData = new ConvertData( SourceFileName: testFile, // ** Always specify a file name with the correct extension SourceFileContent: sourceFile, // ** The file content to convert OutputFormat: ConvertData.OutputFormatEnum.PDF, // ** The format to convert the file to (not all combinations are supported) OverrideSettings: null, // ** Additional settings, see http://blog.muhimbi.com/2012/09/overriding-default-conversion-settings.html TemplateFileContent: null // ** Optional template file, e.g. the InfoPath XSN ); // ** Carry out the conversion Console.WriteLine("[INFO] Converting..."); var response = convertAPI.Convert(inputData); // ** Write the results back to the file system File.WriteAllBytes(@"result.pdf", response.ProcessedFileContent); Console.WriteLine("[INFO] 'result.pdf' written to output folder."); // ** On Windows open the generated file in the system PDF viewer Process.Start(@"result.pdf"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }