static void Main(string[] args) { IInputManager inputManager = new InputManager(); // string path = @"D:\_Projects\_Visual Studio Projects\ConsoleApps\XMLtoHTML\Exercise\Sprint_11945.xml"; // Debug string path = inputManager.GetPath("Enter a path of a .xml file! Format: X:\\..\\..\\filename.xml \n"); HtmlSerializer htmlSerializer = new HtmlSerializer(); XmlDeserializer xmlDeserializer = new XmlDeserializer(); XmlToHtmlConverter xmlToHtmlConverter = new XmlToHtmlConverter(htmlSerializer, xmlDeserializer); xmlToHtmlConverter.Convert(path); }
private static PdfContentInfo ConvertByExternalConverter(IContent contentInfo, CompliantTransformer tx) { byte[] pdfContent = null; ContentInfo content = null; string extension = String.Empty; XmlToHtmlConverter xmlToHtmlConverter = new XmlToHtmlConverter(); byte[] htmlConversion = null; if (xmlToHtmlConverter.IsDocumentProcessable(contentInfo.Extension)) { if (!string.IsNullOrEmpty(tx.CustomStyleContent)) { htmlConversion = xmlToHtmlConverter.Convert(contentInfo.Content, tx.CustomStyleContent, contentInfo.Extension, PathUtil.EXTENSIONPDF, false); } else { htmlConversion = xmlToHtmlConverter.Convert(contentInfo.Content, contentInfo.Extension, PathUtil.EXTENSIONPDF, AttachConversionMode.Default); } } // salvataggio del contenuto in html if (htmlConversion != null) { extension = ".html"; string filename = contentInfo.FileName.Replace(contentInfo.Extension, extension); content = new ContentInfo(filename, htmlConversion); } else { extension = contentInfo.Extension; content = new ContentInfo(contentInfo.FileName, contentInfo.Content); } var converter = PrintRedirectConfigurations.GetConverter(extension); switch (converter) { case ConverterType.OpenOffice: case ConverterType.Redirect: pdfContent = new ExternalRedirectService().Convert(content.Content, content.FileName, "pdf", converter, tx.AttachConversionMode); if (pdfContent.IsNullOrEmpty()) { converter = converter == ConverterType.OpenOffice ? ConverterType.Redirect : ConverterType.OpenOffice; pdfContent = new ExternalRedirectService().Convert(content.Content, content.FileName, "pdf", converter, tx.AttachConversionMode); } break; case ConverterType.Tif: pdfContent = new TifToPdfConverter().Convert(content.Content, content.FileName, "pdf", tx.AttachConversionMode); break; case ConverterType.Image: pdfContent = new ImageToPdfConverter().Convert(content.Content, content.FileName, "pdf", tx.AttachConversionMode); break; case ConverterType.Txt: { pdfContent = new TxtToPdfConverter().Convert(content.Content, content.FileName, "pdf", tx.AttachConversionMode); } break; default: throw new FormatException("CompliantPrintingHelper.ConvertByExternalConverter: formato non supportato."); } if (pdfContent.IsNullOrEmpty()) { throw new InvalidOperationException("CompliantPrintingHelper.ConvertByExternalConverter: conversione fallita."); } return(new PdfContentInfo(content.FileName, pdfContent)); }
public PrintRedirected() { _cacheService = new CacheService(); _pdfToThumbnailConverter = new PdfToThumbnailConverter(); _xmlToHtmlConverter = new XmlToHtmlConverter(); }