/// <summary> /// Initializes a new instance of the <see cref="DocumentInfoContainer"/> class. /// </summary> /// <param name="documentInfo">The document info.</param> /// <param name="options">The options.</param> public DocumentInfoJsonSerializer(DocumentInfoContainer documentInfo, SerializationOptions options) { _documentInfo = documentInfo; _options = options; }
private void ViewDocumentAsImage(ViewDocumentParameters request, ViewDocumentResponse result) { var guid = request.Path; // Get document info var documentInfo = _imageHandler.GetDocumentInfo(guid); // Serialize document info SerializationOptions serializationOptions = new SerializationOptions { UsePdf = request.UsePdf, SupportListOfBookmarks = request.SupportListOfBookmarks, SupportListOfContentControls = request.SupportListOfContentControls }; var documentInfoJson = new DocumentInfoJsonSerializer(documentInfo, serializationOptions) .Serialize(); // Build result result.documentDescription = documentInfoJson; result.docType = documentInfo.DocumentType; result.fileType = documentInfo.FileType; int[] pageNumbers = documentInfo.Pages.Select(_ => _.Number).ToArray(); result.imageUrls = ImageUrlHelper.GetImageUrls(GetApplicationHost(), pageNumbers, request); }
private void ViewDocumentAsHtml(ViewDocumentParameters request, ViewDocumentResponse result) { var guid = request.Path; var fileName = Path.GetFileName(request.Path); // Get document info var documentInfo = _htmlHandler.GetDocumentInfo(guid); // Serialize document info SerializationOptions serializationOptions = new SerializationOptions { UsePdf = false, IsHtmlMode = true, SupportListOfBookmarks = request.SupportListOfBookmarks, SupportListOfContentControls = request.SupportListOfContentControls }; var documentInfoJson = new DocumentInfoJsonSerializer(documentInfo, serializationOptions).Serialize(); // Build html options var htmlOptions = new HtmlOptions { IsResourcesEmbedded = Utils.IsImage(fileName), HtmlResourcePrefix = GetHtmlResourcePrefix(guid), PageNumber = 1, CountPagesToConvert = request.PreloadPagesCount.GetValueOrDefault(1) }; var htmlPageContents = GetHtmlPageContents(guid, htmlOptions); // Build result result.pageHtml = htmlPageContents .Select(_ => _.Html) .ToArray(); result.pageCss = htmlPageContents .Where(_ => !string.IsNullOrEmpty(_.Css)) .Select(_ => _.Css) .ToArray(); result.documentDescription = documentInfoJson; result.docType = documentInfo.DocumentType; result.fileType = GetFileTypeOrEmptyString(documentInfo.FileType); }