// Browse to select input file. private void CmdSelectInputFile_Click(object sender, RoutedEventArgs e) { var dlg = new CommonOpenFileDialog(); dlg.Title = "Choose Entity Upload File"; dlg.IsFolderPicker = false; //dlg.InitialDirectory = currentDirectory; dlg.AddToMostRecentlyUsedList = false; dlg.AllowNonFileSystemItems = false; //dlg.DefaultDirectory = currentDirectory; dlg.EnsureFileExists = true; dlg.EnsurePathExists = true; dlg.EnsureReadOnly = false; dlg.EnsureValidNames = true; dlg.Multiselect = false; dlg.ShowPlacesList = true; dlg.Filters.Add(new CommonFileDialogFilter("CSV File (*.csv)", ".csv")); dlg.Filters.Add(new CommonFileDialogFilter("JSON File (*.json)", ".json")); dlg.Filters.Add(new CommonFileDialogFilter("XML File (*.xml)", ".xml")); if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { InputFile.Focus(); InputFile.Text = dlg.FileName; String filename = dlg.FileName.ToLower(); if (dlg.FileName.EndsWith(".csv")) { UploadFormatCSV.IsChecked = true; } else if (dlg.FileName.EndsWith(".json")) { UploadFormatJSON.IsChecked = true; } if (dlg.FileName.EndsWith(".xml")) { UploadFormatXML.IsChecked = true; } } }
bool fileOrDB = false; // default file storage, true for DB public MainWindow() { InitializeComponent(); InputFile.Focus(); }
private void OK_Click(object sender, System.EventArgs e) { bool result = false; Status.Text = ""; string InFile = InputFile.Text; string OutFile = OutputFile.Text; // check the file names if (InFile.Length == 0) { InputFile.Focus(); return; } if (OutFile.Length == 0) { OutputFile.Focus(); return; } Status.Text = "Converting..."; Status.Refresh(); // do the conversion Dpn dpn = new Dpn(); //dpn.InWebServer = true; //dpn.DpsSetPaperSize(PaperKind.Custom, 12240, 15840); //dpn.DpsSetPaperOrient(false); //dpn.DpsSetPageMargin(720, 720, 720, 720); //dpn.DpsSetPageBorder(Dpn.BRDRTYPE_DBL,30,720,Color.Red); //dpn.DpsSetPageRange(0,0); // example to print just the first page //dpn.OwnerPassword = "******"; //dpn.UserPassword = "******"; //dpn.PermFlags = 0; // Dpn.PERM_COPY | Dpn.PERM_MOD; //dpn.PictQuality = 5; // picture quality, 1=lowest, 5=highest, 3=default //dpn.DoCaching=false; // write directly to disk //dpn.ExactTextPlacement=true; //dpn.MacCompatible=true; //dpn.PdfA=true; // generate pdfA compliant output if (UseBuffer.Checked) { // read the file in the memory buffer and do the conversion byte[] InData = null; string OutData; if ((InData = dpn.DpsFileToBytes(InFile)) != null) { if ((OutData = dpn.DpsConvertBuffer(InData)) != null) { result = dpn.DpsWriteToFile(OutFile, OutData); // write the memory to the output file } } } else { result = dpn.DpsConvertFile(InFile, OutFile); // convert files directly } InputFile.Focus(); // ask for the next file Status.Text = result ? "Done!" : "Error!"; if (result) { try { System.Diagnostics.Process.Start(OutFile); } // display pdf catch { }; } }