iTextSharp动态生成多页pdf及追加内容等记录
- 1.要动态生成pdf,无非是用第三方或直接代码生成。
- 2.iTextSharp生成pdf问题点记录
- dll相关下载
- https://files.cnblogs.com/files/xlgwr/iTextSharAndcode128i.zip
1.初始化代码
string appDomainPath = AppDomain.CurrentDomain.BaseDirectory + @"\";
if (isWebApp)
{
appDomainPath = System.Web.HttpRuntime.AppDomainAppPath + @"bin\";
}
string SavePath = string.Format(@"{0}pdfTemplate\{1}{2}.{3}", appDomainPath, saveFileName, DateTime.Now.ToString("yyyyMMddHHmmssfff"), "pdf");
string ImageLogoPath = string.Format(@"{0}pdfTemplate\{1}.{2}", appDomainPath, "logo", "jpg");
string ImageLogoERcodePath = string.Format(@"{0}pdfTemplate\{1}.{2}", appDomainPath, "logoErcode", "png"); using (Document document = new Document())
{
//中文字体
string chinese = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "simhei.ttf");
BaseFont baseFont = BaseFont.CreateFont(chinese, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
//文字大小12,文字样式
Font cn = new Font(baseFont, 12, Font.NORMAL);
Font fontToLabel = new Font(baseFont, 10, Font.NORMAL, BaseColor.BLACK);
Font fontToValue = new Font(baseFont, 12, Font.BOLD, BaseColor.BLACK);
Font fontToValue8 = new Font(baseFont, 10, Font.BOLD, BaseColor.BLACK);
Font fontLIGHT_GRAY = new Font(baseFont, 10, Font.NORMAL, BaseColor.LIGHT_GRAY); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(@SavePath, FileMode.Create));
document.Open();
PdfContentByte ConByte_Up = writer.DirectContent;//当前页
#region header title //最后一个参数是颜色,这里可以是rgb格式,也可以是默认定义的
Phrase Phr_HeaderTitle = new Phrase("x x 书", new Font(baseFont, 22, Font.BOLD, BaseColor.BLACK));
ColumnText.ShowTextAligned(ConByte_Up, Element.ALIGN_CENTER, Phr_HeaderTitle, 300, 786, 0); //add logo
Image imgLogo = Image.GetInstance(ImageLogoPath);
AddImageToDoc(writer, imgLogo, 3, 744 + imgLogo.Height); Image imgLogoERcode = Image.GetInstance(ImageLogoERcodePath);
AddImageToDoc(writer, imgLogoERcode, 510, 720 + imgLogo.Height, 0.4f); #endregion #region header 头部内容 AddNewLable(dicTitle, "致:", "QHContactPerson", ConByte_Up, fontToLabel, fontToValue, 3, 720); AddNewLable(dicTitle, "我司", "JJCompanyNa", ConByte_Up, fontToLabel, fontToValue, 3, 690);
AddNewLable(dicTitle, "委派", "kyename", ConByte_Up, fontToLabel, fontToValue, 180, 690);
AddNewLable(dicTitle, "于", "GoodsTime", ConByte_Up, fontToLabel, fontToValue, 160 * 2, 690, 20);
AddNewLable(dicTitle, "至贵处取货,请予以配合。", "", ConByte_Up, fontToLabel, fontToValue, 150 * 3, 690);
#endregion float Tleft = 18f;
float TcurrLableYSum = 792 - 72 * 2;
float TcurrLabelWidth = 60f;
float TcurrWidthAdd = 200f;
float TcurrHeigthAdd = 25f; #region header 头部详细内容 792 #region 加背影 ConByte_Up.SetColorFill(BaseColor.LIGHT_GRAY);
ConByte_Up.Rectangle(6, TcurrLableYSum - TcurrHeigthAdd * 4 + 15, 580, TcurrHeigthAdd * 4.3);
ConByte_Up.Fill();
ConByte_Up.Stroke(); ConByte_Up.SetColorStroke(BaseColor.GRAY);
ConByte_Up.MoveTo(TcurrWidthAdd + Tleft - 8, TcurrLableYSum + 20);
ConByte_Up.SetLineDash(3f, 3f);
ConByte_Up.LineTo(TcurrWidthAdd + Tleft - 8, TcurrLableYSum - TcurrHeigthAdd * 2 - 30);
ConByte_Up.Stroke(); ConByte_Up.SetColorStroke(BaseColor.GRAY);
ConByte_Up.MoveTo(TcurrWidthAdd * 2 + Tleft - 8, TcurrLableYSum + 20);
ConByte_Up.SetLineDash(3f, 3f);
ConByte_Up.LineTo(TcurrWidthAdd * 2 + Tleft - 8, TcurrLableYSum - TcurrHeigthAdd * 2 - 30);
ConByte_Up.Stroke(); #endregion
//第一行
AddNewLable(dicTitle, "取货联系人", "QHContactPerson", ConByte_Up, fontToLabel, fontToValue, Tleft, TcurrLableYSum, Element.ALIGN_LEFT, TcurrLabelWidth);
AddNewLable(dicTitle, "寄件公司", "JJCompanyNa", ConByte_Up, fontToLabel, fontToValue, TcurrWidthAdd + Tleft, TcurrLableYSum, Element.ALIGN_LEFT, TcurrLabelWidth);
AddNewLable(dicTitle, "取货司机", "QHMan", ConByte_Up, fontToLabel, fontToValue, (TcurrWidthAdd * 2) + Tleft, TcurrLableYSum, Element.ALIGN_LEFT, TcurrLabelWidth);
//第二行
AddNewLable(dicTitle, "联系方式", "QHContactWay", ConByte_Up, fontToLabel, fontToValue, Tleft, TcurrLableYSum - TcurrHeigthAdd, Element.ALIGN_LEFT, TcurrLabelWidth);
AddNewLable(dicTitle, "寄件人", "JJContactPerson", ConByte_Up, fontToLabel, fontToValue, TcurrWidthAdd + Tleft, TcurrLableYSum - TcurrHeigthAdd, Element.ALIGN_LEFT, TcurrLabelWidth);
AddNewLable(dicTitle, "取货车牌号", "QHCar", ConByte_Up, fontToLabel, fontToValue, (TcurrWidthAdd * 2) + Tleft, TcurrLableYSum - TcurrHeigthAdd, Element.ALIGN_LEFT, TcurrLabelWidth);
//第三行
AddNewLable(dicTitle, "取货地址", "QHAddress", ConByte_Up, fontToLabel, fontToValue8, Tleft, TcurrLableYSum - TcurrHeigthAdd * 2, Element.ALIGN_LEFT, TcurrLabelWidth, true, 200, 15);
AddNewLable(dicTitle, "联系方式", "JJContactWay", ConByte_Up, fontToLabel, fontToValue, TcurrWidthAdd + Tleft, TcurrLableYSum - TcurrHeigthAdd * 2, Element.ALIGN_LEFT, TcurrLabelWidth);
AddNewLable(dicTitle, "司机联系方式", "QHManContactWay", ConByte_Up, fontToLabel, fontToValue, (TcurrWidthAdd * 2) + Tleft, TcurrLableYSum - TcurrHeigthAdd * 2, Element.ALIGN_LEFT, TcurrLabelWidth); //备注
AddNewLable(dicTitle, "备注:", "JJRemark", ConByte_Up, fontToLabel, fontToValue, Tleft, TcurrLableYSum - TcurrHeigthAdd * 4, Element.ALIGN_LEFT, TcurrLabelWidth, true, 550, 15); //签字
AddNewLable(dicTitle, "签字:", "Siger", ConByte_Up, fontToLabel, fontToValue, (TcurrWidthAdd) + Tleft * 3, TcurrLableYSum - TcurrHeigthAdd * 8, 30);
AddNewLable(dicTitle, "日期:", "SigerDate", ConByte_Up, fontToLabel, fontToValue, (TcurrWidthAdd * 2), TcurrLableYSum - TcurrHeigthAdd * 8, 30); #endregion var getPageOne = dicList.Take(2);
#region 明细第一页,最多两个 AddListDetails(dicTitle, fontToLabel, fontToValue, fontToValue8, fontLIGHT_GRAY,
writer, ConByte_Up, TcurrLableYSum - TcurrHeigthAdd * 10, TcurrHeigthAdd, getPageOne); //页数
string pageSize = string.Format("页码:{0}/{1}", 1, 1); #endregion #region 明细第n页,每页最多4个
var getPageGetMoreTow = dicList.Skip(2); var currNextList = getPageGetMoreTow.Take(4);
var AllPageSize = Math.Ceiling(getPageGetMoreTow.Count() / 4F);
if (AllPageSize > 0)
{
AllPageSize++;
pageSize = string.Format("页码:{0}/{1}", 1, AllPageSize);
}
AddNewLable(dicTitle, pageSize, "", ConByte_Up, fontToLabel, fontToValue, 300, 10, Element.ALIGN_CENTER); int runNM = 0;
while (currNextList.Count() > 0)
{
//新页面
document.NewPage(); AddListDetails(dicTitle, fontToLabel, fontToValue, fontToValue8, fontLIGHT_GRAY,
writer, ConByte_Up, 800, TcurrHeigthAdd, currNextList, true); //下次
runNM++;
currNextList = getPageGetMoreTow.Skip(4 * runNM).Take(4); //页数
pageSize = string.Format("页码:{0}/{1}", runNM + 1, AllPageSize);
AddNewLable(dicTitle, pageSize, "", ConByte_Up, fontToLabel, fontToValue, 300, 10, Element.ALIGN_CENTER);
} #endregion ////新页面
//document.NewPage();
//AddImageToDoc(writer, imgLogo, 3, 744 + imgLogo.Height);
//AddImageToDoc(writer, imgLogoERcode, 510, 720 + imgLogo.Height, 0.4f); }
2.小方法
private int AddListDetails(Dictionary<string, string> dicTitle, Font fontToLabel, Font fontToValue, Font fontToValue8,
Font fontLIGHT_GRAY, PdfWriter writer, PdfContentByte ConByte_Up, float TcurrBaseY, float TcurrHeigthAdd, IEnumerable<Dictionary<string, string>> getPageOne, bool hasPage = false)
{
int beseRun = 0;
foreach (var item in getPageOne)
{
if (!hasPage)
{
AddNewLable(dicTitle, "--------------------------------------------------由此撕开--------------------------------------------------", "",
ConByte_Up, fontLIGHT_GRAY, fontToValue, 300, TcurrBaseY - TcurrHeigthAdd * (beseRun * 8) + TcurrHeigthAdd, Element.ALIGN_CENTER);
} if (item.ContainsKey("YDCode"))
{
var YDCode = item["YDCode"];
//插入图片128
var ydcode1Image = GetImageCode128(YDCode);
var ydcode1ImageToPost = GetImageToPoint(ydcode1Image, 0.45f, 0, TcurrBaseY - TcurrHeigthAdd * (beseRun * 8) - TcurrHeigthAdd * 3.5f);
writer.DirectContent.AddImage(ydcode1ImageToPost);
} AddNewLable(item, "", "YDCode", ConByte_Up, fontToLabel, fontToValue, 20, TcurrBaseY - TcurrHeigthAdd * (beseRun * 8) - TcurrHeigthAdd * 4);
AddNewLable(item, "收件公司:", "SJCompanyNa", ConByte_Up, fontToLabel, fontToValue, 180, TcurrBaseY - TcurrHeigthAdd * (beseRun * 8), Element.ALIGN_LEFT, 45);
AddNewLable(item, "收件地址", "SJAddress", ConByte_Up, fontToLabel, fontToValue8, 380, TcurrBaseY - TcurrHeigthAdd * (beseRun * 8), Element.ALIGN_LEFT, 45, true, 550, 18); if (item.ContainsKey("DeliveryDetail"))
{
var getdeliveryDetails = item["DeliveryDetail"].JsonTo<List<GoodsInfo>>();
if (getdeliveryDetails != null && getdeliveryDetails.Count > 0)
{
ConByte_Up.SetColorFill(BaseColor.LIGHT_GRAY);
ConByte_Up.Rectangle(180 - 2, TcurrBaseY - TcurrHeigthAdd * (2 + beseRun * 8) - 3, 380, 15);
ConByte_Up.Fill();
ConByte_Up.Stroke(); //货物详情明细:
AddNewLable(item, "型号", "", ConByte_Up, fontToLabel, fontToValue, 180, TcurrBaseY - TcurrHeigthAdd * (2 + beseRun * 8), Element.ALIGN_LEFT, 45, true, 550, 15);
AddNewLable(item, "名称", "", ConByte_Up, fontToLabel, fontToValue, 180 + 80 * 1, TcurrBaseY - TcurrHeigthAdd * (2 + beseRun * 8), Element.ALIGN_LEFT, 45, true, 550, 15);
AddNewLable(item, "件数", "", ConByte_Up, fontToLabel, fontToValue, 180 + 80 * 2, TcurrBaseY - TcurrHeigthAdd * (2 + beseRun * 8), Element.ALIGN_LEFT, 45, true, 550, 15);
AddNewLable(item, "其它内容1", "", ConByte_Up, fontToLabel, fontToValue, 180 + 80 * 3, TcurrBaseY - TcurrHeigthAdd * (2 + beseRun * 8), Element.ALIGN_LEFT, 45, true, 550, 15);
AddNewLable(item, "其它内容2", "", ConByte_Up, fontToLabel, fontToValue, 180 + 80 * 4, TcurrBaseY - TcurrHeigthAdd * (2 + beseRun * 8), Element.ALIGN_LEFT, 45, true, 550, 15); int currRun2 = 0;
foreach (var item2 in getdeliveryDetails)
{
AddNewLable(item, item2.Model, "", ConByte_Up, fontToValue8, fontToLabel, 180, TcurrBaseY - TcurrHeigthAdd * (3 + beseRun * 8) - currRun2 * TcurrHeigthAdd, Element.ALIGN_LEFT, 45, true, 550, 15);
AddNewLable(item, item2.Name, "", ConByte_Up, fontToValue8, fontToLabel, 180 + 80 * 1, TcurrBaseY - TcurrHeigthAdd * (3 + beseRun * 8) - currRun2 * TcurrHeigthAdd, Element.ALIGN_LEFT, 45, true, 550, 15);
AddNewLable(item, item2.Quantity, "", ConByte_Up, fontToValue8, fontToLabel, 180 + 80 * 2, TcurrBaseY - TcurrHeigthAdd * (3 + beseRun * 8) - currRun2 * TcurrHeigthAdd, Element.ALIGN_LEFT, 45, true, 550, 15);
AddNewLable(item, item2.Other1, "", ConByte_Up, fontToValue8, fontToLabel, 180 + 80 * 3, TcurrBaseY - TcurrHeigthAdd * (3 + beseRun * 8) - currRun2 * TcurrHeigthAdd, Element.ALIGN_LEFT, 45, true, 550, 15);
AddNewLable(item, item2.Other2, "", ConByte_Up, fontToValue8, fontToLabel, 180 + 80 * 4, TcurrBaseY - TcurrHeigthAdd * (3 + beseRun * 8) - currRun2 * TcurrHeigthAdd, Element.ALIGN_LEFT, 45, true, 550, 15); currRun2++;
}
}
else
{
//货物详情:
AddNewLable(item, "货物详情:", "DeliveryDetail", ConByte_Up, fontToLabel, fontToValue, 180, TcurrBaseY - TcurrHeigthAdd * (2 + beseRun * 8), Element.ALIGN_LEFT, 45, true, 550, 15); }
}
else
{
//货物详情:
AddNewLable(item, "货物详情:", "DeliveryDetail", ConByte_Up, fontToLabel, fontToValue, 180, TcurrBaseY - TcurrHeigthAdd * (2 + beseRun * 8), Element.ALIGN_LEFT, 45, true, 550, 15); } beseRun++; if (beseRun < getPageOne.Count())
{
AddNewLable(dicTitle, "--------------------------------------------------由此撕开--------------------------------------------------", "",
ConByte_Up, fontLIGHT_GRAY, fontToValue, 300, TcurrBaseY - TcurrHeigthAdd * (beseRun * 8) + TcurrHeigthAdd, Element.ALIGN_CENTER);
}
} return beseRun;
} private static void AddNewLable(Dictionary<string, string> dic, string lableName, string keyName, PdfContentByte ConByte_Up, Font fontToLabel, Font fontToValue, float x, float y, int ealign = Element.ALIGN_LEFT, float w = 30, bool isMuli = false, float muliWidth = 130, float muliHeightAdd = 30, float rotation = 0)
{
if (y <= 0)
{
y = 10;
}
if (!lableName.IsNullOrEmpty())
{
Phrase Phr_lable = new Phrase(lableName, fontToLabel);
ColumnText.ShowTextAligned(ConByte_Up, ealign, Phr_lable, x, y, rotation);
} string GetValue = dic.ContainsKey(keyName) ? dic[keyName] : "";
if (!GetValue.IsNullOrEmpty())
{
if (isMuli)
{
ColumnText column = new ColumnText(ConByte_Up);
column.SetSimpleColumn(new Phrase(GetValue, fontToValue), muliWidth, 0, x + w, y + muliHeightAdd, 15, Element.ALIGN_TOP); column.Go();
}
else
{ Phrase Phr_Value = new Phrase(GetValue, fontToValue);
ColumnText.ShowTextAligned(ConByte_Up, ealign, Phr_Value, x + w, y, rotation);
}
}
} private static void AddImageToDoc(PdfWriter writer, Image img, float x, float y, float percent = 1)
{
//这里用计算出来的百分比来缩小图片
img.ScalePercent(percent * 100);
//图片定位,页面总宽283,高416;这里设置0,0的话就是页面的左下角 让图片的中心点与页面的中心店进行重合
img.SetAbsolutePosition(x, y);
writer.DirectContent.AddImage(img);
} /// <summary>
/// 用于xx书
/// </summary>
public string PDFWithAddImage(string filePath, string filePath2, string ydcode1)
{
using (Stream inputPdfStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream outputPdfStream = new FileStream(filePath2, FileMode.Create, FileAccess.Write, FileShare.None))
{
var reader = new PdfReader(inputPdfStream);
var stamper = new PdfStamper(reader, outputPdfStream);
var pdfContentByte = stamper.GetOverContent(1); //插入图片
var ydcode1Image = GetImageCode128(ydcode1);
//var ydcode2Image = GetImageCode128(ydcode1); var ydcode1ImageToPost = GetImageToPoint(ydcode1Image, 0.5f, 2, 340);
var ydcode2ImageToPost = GetImageToPoint(ydcode1Image, 0.5f, 2, 170); pdfContentByte.AddImage(ydcode1ImageToPost);
pdfContentByte.AddImage(ydcode2ImageToPost); stamper.Close();
}
return filePath2; }
public Image GetImageToPoint(System.Drawing.Image image, float percentage, float x, float y)
{
Image img = Image.GetInstance(image, System.Drawing.Imaging.ImageFormat.Bmp); //这里用计算出来的百分比来缩小图片
img.ScalePercent(percentage * 100); img.ScaleAbsoluteHeight(img.PlainHeight * 4); //图片定位,页面总宽283,高416;这里设置0,0的话就是页面的左下角 让图片的中心点与页面的中心店进行重合
img.SetAbsolutePosition(x, y);
return img;
}
public void DeleteFile(string saveFilePath)
{
try
{
File.Delete(saveFilePath);
}
catch (Exception ex)
{
}
}
3 字体相关
//设置支持中文字体
BaseFont baseFont = BaseFont.CreateFont("C:\\WINDOWS\\FONTS\\msyhbd.TTC,0", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
pdfFormFields.AddSubstitutionFont(baseFont);
4 条码
public System.Drawing.Image GetImageCode128(string codetext)
{
System.Drawing.Image ydcodeImage = Code128Rendering.MakeBarcodeImage(codetext, 2, true); return ydcodeImage;
}
5 获对象属性值
public Dictionary<string, string> getProperties<T>(T t)
{
Dictionary<string, string> tStr = new Dictionary<string, string>();
if (t == null)
{
return tStr;
}
System.Reflection.PropertyInfo[] properties = t.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); if (properties.Length <= 0)
{
return tStr;
}
foreach (System.Reflection.PropertyInfo item in properties)
{
string name = item.Name;
object value = item.GetValue(t, null);
if (item.PropertyType.IsValueType || item.PropertyType.Name.StartsWith("String"))
{
tStr.Add(name, value.ToNotNullString());
}
}
return tStr;
}
6 向pdf中加内容图片什么的
public string PDFWithAddImage(string filePath, string filePath2, string ydcode1)
{
using (Stream inputPdfStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream outputPdfStream = new FileStream(filePath2, FileMode.Create, FileAccess.Write, FileShare.None))
{
var reader = new PdfReader(inputPdfStream);
var stamper = new PdfStamper(reader, outputPdfStream);
var pdfContentByte = stamper.GetOverContent(1); //插入图片
var ydcode1Image = GetImageCode128(ydcode1);
//var ydcode2Image = GetImageCode128(ydcode1); var ydcode1ImageToPost = GetImageToPoint(ydcode1Image, 0.5f, 2, 340);
var ydcode2ImageToPost = GetImageToPoint(ydcode1Image, 0.5f, 2, 170); pdfContentByte.AddImage(ydcode1ImageToPost);
pdfContentByte.AddImage(ydcode2ImageToPost); stamper.Close();
}
return filePath2; }
iTextSharp动态生成多页pdf及追加内容等记录的更多相关文章
- EasyUI中动态生成标签页
这是最近学到的内容,当时是有思路但是不知道怎么获取当前的点击对象,就没有实现功能,通过更深入的学习,我知道了不仅仅是Java,Oracle中有一个this,同样的EasyUI中也存在一个this,来获 ...
- C#动态生成html页
Html生成模块:WriteHtml.cs using System.Collections.Generic; using System.IO; using System.Text; namespac ...
- Phantomjs 生成多页PDF
开篇 最近使用 Phantomjs 生成PDF,其中遇到一些问题,导致PDF生成失败,如出现空白文件或一页数据量太大,都是由于没有设置好格式导致.特别是分页问题,感觉资料很少,除了在 StackOve ...
- 根据html页面模板动态生成html页面(c#类)
本文转载自:http://www.cnblogs.com/yuanbao/archive/2008/01/06/1027985.html点击打开链接 一直以为动态生成静态页面不好做,昨天在网上找了下, ...
- 使用 ItextSharp HTML生成Pdf(C#)
以前生成pdf的时候.因为生成的pdf数据是固定的,所以先做好pdf模板,动态的数据可以先用占位符 生成的时候.找到占位符坐标.把数据填充进去 优点:先做好模板.生成的pdf 表格.文.内容会好看一些 ...
- 利用Java动态生成 PDF 文档
利用Java动态生成 PDF 文档,则需要开源的API.首先我们先想象需求,在企业应用中,客户会提出一些复杂的需求,比如会针对具体的业务,构建比较典型的具备文档性质的内容,一般会导出PDF进行存档.那 ...
- Java 动态生成 PDF 文件
每片文章前来首小诗: 今日夕阳伴薄雾,印着雪墙笑开颜.我心仿佛出窗前,浮在半腰望西天. --泥沙砖瓦浆木匠 需求: 项目里面有需要java动态生成 PDF 文件,提供下载.今天我找了下有关了,系 ...
- 动态生成html元素并为元素追加属性
动态生成HTML元素的方法有三种: 第一种:document.createElement()创建元素,再用appendChild( )方法将元素添加到指定节点 <!DOCTYPE html> ...
- java根据模板HTML动态生成PDF
原文:https://segmentfault.com/a/1190000009160184 一.需求说明:根据业务需要,需要在服务器端生成可动态配置的PDF文档,方便数据可视化查看. 二.解决方案: ...
随机推荐
- [19/03/25-星期一] 容器_Collection(集合、容器)之Set(集合、安置,无顺序不可重复)
一.概念&方法 Set接口继承自Collection,Set接口中没有新增方法,方法和Collection保持完全一致.. Set容器特点:无序.不可重复.无序指Set中的元素没有索引,只能遍 ...
- 时钟系统与UART
关于时钟设置原理: 关于如何设置系统时钟的思路. 其中锁定时间需要一个寄存器,PLL需要一个寄存器(MPLLCL),分频还需要一个寄存器,总计三个寄存器.步骤如下: 1. 上电后,FCLK=Fin 2 ...
- 使用Scanner将InputStream类型转换成String
我们在测试项目中经常会遇到这样的情形: 1. 从文件或网络得到一个InputStream,需要转换成String赋值到别的变量做为另一个方法的入参. 2. 从文件或网络得到一个InputStream后 ...
- C#制作ActiveX浏览器插件.net
开发环境:VS2008 第一步 创建项目 新建一个项目,选择“Windows窗体控件库”,创建一个用户控件项目“ActiveXDemo”(注意,这里起名不能用中文,否则后面会出问题),里面有个用户控件 ...
- Many-to-many relationships in EF Core 2.0 – Part 4: A more general abstraction
In the last few posts we saw how to hide use of the join entity from two entities with a many-to-man ...
- OC之block 和协议
一.BOLCK (一)简介 BLOCK是什么?苹果推荐的类型,效率高,在运行中保存代码.用来封装和保存代码,有点像函数,BLOCK可以在任何时候执行. BOLCK和函数的相似性:(1)可以保存代码(2 ...
- CGAffineTransform 视频旋转(转)
记录下视频旋转 ////////////////////////////////////////////// - (void)test:(NSURL *)url transformUrl:(NSURL ...
- 给出一个整数,将这个整数中每位上的数字进行反转(JavaScript编程)
一.问题描述:给出一个整数,将这个整数中每位上的数字进行反转.示例:输入:123,输出321:输入-123,输出-321:输入120,输出-21 二.问题分析与解决: 需要将给出的整数反转,注意示例中 ...
- df du sync
df命令用来检查linux系统的磁盘空间占用情况 df [选项] -h:以容易理解的格式输出文件系统分区占用情况,如32KB,120MB,60GB -k:以KB大小单位输出文件系统分区占用情况 -m: ...
- centos6,python3,通过pip安装pycurl出现报错提示
Centos6.7系统,python3.6.7,通过 pip 安装pycurl出现报错: __main__.ConfigurationError: Could not run curl-config: ...