/// <summary> /// Returns a page xml object for the page xml in <paramref name="path"/> /// </summary> /// <param name="path">Path to the page xml file.</param> /// <returns>page xml object</returns> public static PageXml GetPageXml(string path) { string pageXmlNamespace = PageXml.GetNamespace(path); switch (pageXmlNamespace) { case V2_NAMESPACE: return(new PageXmlV2(path)); case V3_NAMESPACE: return(new PageXmlV3(path)); default: return(new PageXmlV2(path)); } }
private void DoTiffXMLIngestion(ref BackgroundWorker Slave, string LangName, string FontID, string TiffXMLFolder, bool UseSubList) { double Increment = 1; if (FontID != "" && FontID != "" && TiffXMLFolder != "") { App_Code.Font myFont = new App_Code.Font(FontID, true, true); string FullInputDir = TiffXMLFolder + "\\"; string FullOutputDir = db.DataDirectory + "\\GlyphExtraction\\Output\\" + myFont.ID; string[] InputFiles = System.IO.Directory.GetFiles(FullInputDir, "*.xml", SearchOption.TopDirectoryOnly); if (InputFiles.Count() > 0) { Increment = 50 / InputFiles.Count(); } int CurrentProgress = 0; foreach (string F in InputFiles) { if (Slave.CancellationPending) { break; } else { string inputFileName = F.Replace(FullInputDir, ""); if (inputFileName.EndsWith(".xml") && File.Exists(F.Replace(".xml", ".tif"))) { if (!System.IO.Directory.Exists(FullOutputDir + "\\" + inputFileName.Replace(".xml", ""))) { System.IO.Directory.CreateDirectory(FullOutputDir + "\\" + inputFileName.Replace(".xml", "")); } ProcessStatus = "Extracting " + inputFileName + "..."; Slave.ReportProgress(((int)(CurrentProgress * Increment))); string inputImageFilePath = FullInputDir + inputFileName.Replace(".xml", ".tif"); string inputXmlFilePath = FullInputDir + inputFileName; string outputFolderPath = FullOutputDir + "\\" + inputFileName.Replace(".xml", ""); PageXml pageXml = PageXmlFactory.GetPageXml(F); string extractor = pageXml.ImageExtratorRelPath; string command = string.Format(@"{0}\GlyphExtraction\{1}", db.DataDirectory, extractor); FileInfo extractorExec = new FileInfo(command); string options = pageXml.CreateImageExtractorCommandLine(inputImageFilePath, inputXmlFilePath, outputFolderPath); ExecuteCommand(command, options, extractorExec.DirectoryName); CurrentProgress++; ProcessStatus = "Processing extracted images..."; Slave.ReportProgress(((int)(CurrentProgress * Increment))); myFont.IngestImages(LangName, myFont.Name, inputFileName.Replace(".xml", ""), FullInputDir + "\\" + inputFileName, FullOutputDir + "\\" + inputFileName.Replace(".xml", ""), UseSubList); } } CurrentProgress++; ProcessStatus = "Moving to next TIF/XML pair..."; Slave.ReportProgress(((int)(CurrentProgress * Increment))); } } }