LibreOffice-val dokumentum konvertálása PDF-re most jó
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using DocumentFormat.OpenXml.Office.CustomUI;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Serilog;
|
||||
@@ -424,18 +425,40 @@ namespace WorkFlowCheck.BL.Services
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public byte[] CreatePDF(int checkListHeaderId)
|
||||
public async Task<byte[]> CreatePDF(int checkListHeaderId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var checkListHeader = await this.GetCheckListHeaderAsync(checkListHeaderId);
|
||||
|
||||
string pdfDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Pdf");
|
||||
|
||||
byte[] byteArray = File.ReadAllBytes(Path.Combine(pdfDirectory, "CheckList_Template_V1.docx"));
|
||||
SablonGenerator gen = new SablonGenerator(byteArray);
|
||||
|
||||
if (checkListHeader.CheckListRowDTO != null && checkListHeader.CheckListRowDTO.Count > 0)
|
||||
{
|
||||
var elements = new List<List<string>>();
|
||||
foreach (var item in checkListHeader.CheckListRowDTO)
|
||||
{
|
||||
if (item.CheckListTemplateRowDTO != null)
|
||||
{
|
||||
var cells = new List<string>
|
||||
{
|
||||
$"{item.CheckListTemplateRowDTO.RowIndex.ToString()}.",
|
||||
item.CheckListTemplateRowDTO.OperationDescription,
|
||||
item.Answer
|
||||
};
|
||||
elements.Add(cells);
|
||||
}
|
||||
}
|
||||
gen.SetTable(elements, "#rowindex");
|
||||
}
|
||||
|
||||
|
||||
byte[] content = gen.CloseAndGetDocument();
|
||||
|
||||
return DokumentumGenerator.DocxToPdf(content);
|
||||
return DokumentumGenerator.DocxToPdfL(content);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,6 @@ namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
Task<CheckListRowDTO> UpdateCheckListRowAsync(CheckListRowDTO checkListRowDTO);
|
||||
|
||||
|
||||
byte[] CreatePDF(int checkListHeaderId);
|
||||
Task<byte[]> CreatePDF(int checkListHeaderId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user