|
@@ -1,16 +1,16 @@
|
|
|
using Common;
|
|
|
-using LisPacsDataUpload.Models;
|
|
|
+using iTextSharp.text;
|
|
|
+using iTextSharp.text.pdf;
|
|
|
using LisPacsDataUpload.Models.Report;
|
|
|
using Newtonsoft.Json;
|
|
|
using System;
|
|
|
-using System.Collections.Generic;
|
|
|
using System.Configuration;
|
|
|
using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Reflection;
|
|
|
-using System.Text;
|
|
|
+
|
|
|
|
|
|
namespace LisPacsDataUpload.business
|
|
|
{
|
|
@@ -94,16 +94,57 @@ namespace LisPacsDataUpload.business
|
|
|
}
|
|
|
return zlsoftOutVO.input.file_info.rpt_content;
|
|
|
}
|
|
|
- else
|
|
|
+ else if(lisVersion == 3)
|
|
|
{
|
|
|
// 三方lis
|
|
|
+ string three_sql = @"select pdfUrl from three_lis_pdf where yzid =" + bbid;
|
|
|
+ LogHelper.Info("three_sql "+ three_sql);
|
|
|
+ DataRow data = SqlServerHelper.ExecuteSingleRowQuery(three_sql);
|
|
|
+ if (data!=null)
|
|
|
+ {
|
|
|
+ string jpgUrl = data["pdfUrl"].ToString();
|
|
|
+ LogHelper.Info("三方原始jpgUrl" + jpgUrl);
|
|
|
+ GetPdfFromJpg(jpgUrl, path);
|
|
|
+ return path;
|
|
|
+ }
|
|
|
+ return "三方lispdf报告获取失败";
|
|
|
}
|
|
|
return "失败";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static void GetPdfFromJpg(string jpgUrl,string pdfUrl)
|
|
|
+ {
|
|
|
+ LogHelper.Info("开始从jpg转换pdf");
|
|
|
+ //string jpgFilePath = "path_to_your_jpg.jpg";
|
|
|
+ //string pdfFilePath = "output.pdf";
|
|
|
+
|
|
|
+ using (FileStream fs = new FileStream(pdfUrl, FileMode.Create))
|
|
|
+ {
|
|
|
+ // 创建一个文档对象
|
|
|
+ Document document = new Document();
|
|
|
+ // 创建一个 PDF 写入器,将文档写入文件流
|
|
|
+ PdfWriter writer = PdfWriter.GetInstance(document, fs);
|
|
|
+
|
|
|
+ document.Open();
|
|
|
+
|
|
|
+ // 创建一个图像对象并加载 JPG 文件
|
|
|
+ Image image = Image.GetInstance(jpgUrl);
|
|
|
+ // 设置图像在 PDF 中的尺寸(可以根据需要调整)
|
|
|
+ image.ScaleToFit(document.PageSize.Width - 20, document.PageSize.Height - 20);
|
|
|
+
|
|
|
+ // 将图像添加到 PDF 文档中
|
|
|
+ document.Add(image);
|
|
|
+ document.Close();
|
|
|
+ }
|
|
|
+ LogHelper.Info("JPG 转换为 PDF 成功!");
|
|
|
+ }
|
|
|
+
|
|
|
public static string GeneratePdf(int lisVersion, string reportNumber, string bbid)
|
|
|
{
|
|
|
- return getPdfParamByLisVersion(lisVersion, reportNumber, bbid);
|
|
|
+ string pdfUrl = getPdfParamByLisVersion(lisVersion, reportNumber, bbid);
|
|
|
+ LogHelper.Info("GeneratePdf==" + pdfUrl);
|
|
|
+ return pdfUrl;
|
|
|
}
|
|
|
|
|
|
|