using (WebClient webClient_ = new WebClient())
{
webClient_.DownloadFile(imageURL, fileName);
}
using (WebClient webClient_ = new WebClient())
{
byte[] data_ = webClient_.DownloadData(imageURL);
MemoryStream mem_= new MemoryStream(data_);
}
using (FileStream wfs = new FileStream(filePath, FileMode.OpenOrCreate))
{
PdfWriter wr_ = PdfWriter.GetInstance(_doc, wfs);
_doc.Open();
float[] clos = new float[] { 40, 40, 40 };// 寬度
PdfPTable tablerow1 = new PdfPTable(clos);
foreach (string t in title)
{
PdfPCell cell = new PdfPCell(new Paragraph(t))
{
MinimumHeight = 4f
};
tablerow1.AddCell(cell);
}
List<string> list = new List<string>()
{
"ABC",
"cde",
"FgH"
};
foreach (var d in list)
{
tablerow1.AddCell(new PdfPCell(image, true));
tablerow1.AddCell(new PdfPCell(new Paragraph(d + d)));
tablerow1.AddCell(new PdfPCell(new Paragraph(d)));
}
_doc.Add(tablerow1);//將表格添加到pdf文檔中
_doc.Close();//關閉
wr_.Close();
wfs.Close();
}
using (MemoryStream mem_ = new MemoryStream())
{
PdfWriter wr_ = PdfWriter.GetInstance(_doc, mem_);
_doc.Open();
float[] clos = new float[] { 40, 40, 40 };// 寬度
PdfPTable tablerow1 = new PdfPTable(clos);
foreach (string t in title)
{
PdfPCell cell = new PdfPCell(new Paragraph(t))
{
MinimumHeight = 4f
};
tablerow1.AddCell(cell);
}
List<string> list = new List<string>()
{
"ABC",
"cde",
"FgH"
};
foreach (var d in list)
{
tablerow1.AddCell(new PdfPCell(image, true));
tablerow1.AddCell(new PdfPCell(new Paragraph(d + d)));
tablerow1.AddCell(new PdfPCell(new Paragraph(d)));
}
_doc.Add(tablerow1);//將表格添加到pdf文檔中
_doc.Close();//關閉
wr_.Close();
return mem_.ToArray();
}
如果 MemoryStream 要再使用,必須先轉成 byte[],之後再宣告 MemoryStream 來使用
Attachment a_ = new Attachment(new MemoryStream(ms_.ToArray()), ct);
透過 new MemoryStream(ms_.ToArray()) 後,Attachment a_ 才能真正取的檔案內容
工作紀錄
巴哈姆特-唯舞獨尊 Online 介紹網頁
May 4, 2025下載 Cascadia.ttf 安裝 CaskaydiaCove 字型 檔案總管右鍵會有一個安裝選項安裝完後開啟 VSCodeVSCode 也可以點選 在 settings.json 內編輯新增下列設定即可 { "workbench.startupEditor": "newUntitledFile", "editor.fontFamily": "'Cascadia Code', Consolas, 'Courier New', monospace",
Apr 10, 2023VSCode 必裝套件 2021 年補充 Cascadia Code 字型 VSCode 安裝 Cascadia Code Cascadia Code 微軟釋出免費等寬字型,開源更適合程式碼編輯器和終端機 Coding 用字體推薦:Fira Code、JetBrains Mono、Consolas、與 Input Sans JetBrains Mono 更適合閱讀程式碼的等寬字型,內建四種字重斜體可商用
Apr 7, 2023停用硬體加速(省電省記憶體, ==高配請忽視==) Viasfora 大刮號變色、關鍵字變色  Code alignment 自動對齊工具 
Sep 25, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up