C#版 iText7——画发票PDF(完整)

显示描述:
1、每页显示必须带有发票头、“销售方和购买方信息”
2、明细填充为:当n≤8 行时,发票总高度140mm,每条发票明细行款高度4.375mm;
当8<n≤12行时,发票高度增加17.5mm,不换页;
以此类推
根据实际情况能放下“应税明细信息”和“票尾”信息后换页,注意是否为最后一行
3、超过一页,则每页显示小计

显示效果:
1、只有一页的情况:
在这里插入图片描述
2、有两页的且刚好能放下所有明细的情况(超过一页后,开票日期下显示页数):
这是第一页
在这里插入图片描述

代码实现:

步骤一、创建主方法,可传入需要的参数模型

public static void InvoicePage(NaturalSystemPdfModel model) //NaturalSystemPdfModel为传入的需要用到的参数模型
{//创建pdf的保存位置//model.filePath为传入模型中存放的文件保存路径,model.kprq为开票日期,model.fileName为文件名//model.filePath = Path.Combine(_webHostEnvironment.WebRootPath, “.pdf”);获取当前服务器下的文件路径string outputPath = Path.Combine(model.filePath,model.kprq.ToString("yyyyMMdd"), model.fileName + ".pdf");//判断文件夹是否存在,不存在则创建一个新的if (!Directory.Exists(Path.Combine(model.filePath, model.kprq.ToString("yyyyMMdd"))))Directory.CreateDirectory(Path.Combine(model.filePath, model.kprq.ToString("yyyyMMdd")));// 创建一个新的PDF文档var cc = new PdfWriter(outputPath);//设置 PdfStream默认压缩级别。cc.SetCompressionLevel(CompressionConstants.BEST_COMPRESSION);PdfDocument pdf = new PdfDocument(cc);model.jshjdx = MoneyToUpper(model.jshj.ToString()); //价税合计大写转换(转换方法MoneyToUpper())model.gmfmc = model.gmfmc == "个人" ? model.gmfmc + "(个人)" : model.gmfmc;//购方名称字体//model.webHost为模型中的发布服务器中的文件所在位置:IWebHostEnvironment _webHostEnvironment.WebRootPathPdfFont KT = PdfFontFactory.CreateFont(System.IO.Path.Combine(model.webHost, "fonts", "SIMKAI.TTF"), PdfEncodings.IDENTITY_H, PdfFontFactory.EmbeddingStrategy.PREFER_NOT_EMBEDDED);PdfFont ST = PdfFontFactory.CreateFont(System.IO.Path.Combine(model.webHost, "fonts", "SIMFANG.TTF"), PdfEncodings.IDENTITY_H, PdfFontFactory.EmbeddingStrategy.PREFER_NOT_EMBEDDED);PdfFont CN = PdfFontFactory.CreateFont(System.IO.Path.Combine(model.webHost, "fonts", "COUR.TTF"), PdfEncodings.IDENTITY_H, PdfFontFactory.EmbeddingStrategy.PREFER_NOT_EMBEDDED);//添加页眉页脚||或者需要每页显示的票头//创建类PdfEventHandler,在步骤二中PdfEventHandler handler = new PdfEventHandler(model, KT, ST, CN);//发票中的票头、购买方信息、表头都放在PdfEventHandler类中pdf.AddEventHandler(PdfDocumentEvent.START_PAGE, handler);ComputeValue computeValue = new ComputeValue();try{using (Document document = new Document(pdf, iText.Kernel.Geom.PageSize.A4, false)){//document.SetMargins(0, 0, 0, 0);//默认宽210mm=8.2677英寸=595磅//默认高29.7mm=11.6929英寸=842磅//默认边距36磅=0.5英寸=12.7mm// 定义自定义RGB颜色(例如,红色)DeviceRgb customColor = new DeviceRgb(128, 0, 0);//发票固定高度pt:票头,ht:购买方信息,et:票尾备注,kp:开票人float pt = 30, ht = 22, et = 20, kp = 8.5f;//下面代码中大量用到的computeValue.computeUnit()方法作用为:毫米转换磅#region 表中列表 //添加表格Table BodyTable = new Table(9, false);Cell cel11 = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetWidth(computeValue.computeUnit(37)).SetHeight(computeValue.computeUnit(4.5f)).SetBorderRight(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("项目名称"));Cell cel12 = new Cell(1, 2).SetTextAlignment(TextAlignment.LEFT).SetWidth(computeValue.computeUnit(24)).SetBorder(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("规格型号"));Cell cel13 = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetWidth(computeValue.computeUnit(12)).SetBorder(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("单位"));Cell cel14 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(25)).SetBorder(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("数量"));Cell cel15 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(25)).SetBorder(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("单价"));Cell cel16 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(26)).SetBorder(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("金额"));Cell cel17 = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetBorder(Border.NO_BORDER).SetWidth(computeValue.computeUnit(25)).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("税率/征收率"));Cell cel18 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(27)).SetBorderLeft(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("税额"));BodyTable.AddCell(cel11.SetBorder(new SolidBorder(customColor, 1)));BodyTable.AddCell(cel12);BodyTable.AddCell(cel13);BodyTable.AddCell(cel14);BodyTable.AddCell(cel15);BodyTable.AddCell(cel16);BodyTable.AddCell(cel17);BodyTable.AddCell(cel18.SetBorder(new SolidBorder(customColor, 1)));BodyTable.StartNewRow();//合计小计列//合计Cell cel41 = new Cell(1, 2).SetTextAlignment(TextAlignment.CENTER).SetHeight(computeValue.computeUnit(4.5f)).SetPaddingBottom(-5).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("合\t\t计").SetFixedLeading(11));Cell cel42 = new Cell(1, 5).SetTextAlignment(TextAlignment.RIGHT).SetHeight(computeValue.computeUnit(4.5f)).SetFont(ST).SetFontSize(9).Add(new Paragraph("¥" + model.hjje).SetFixedLeading(11));Cell cel43 = new Cell(1, 2).SetTextAlignment(TextAlignment.RIGHT).SetHeight(computeValue.computeUnit(4.5f)).SetFont(ST).SetFontSize(9).Add(new Paragraph("¥" + model.hjse).SetFixedLeading(11));//价税合计大小写ImageData data = ImageDataFactory.Create(Path.Combine(model.webHost, "images", "jiashuiheji.png"));Image img = new Image(data).SetWidth(15).SetHeight(15);Cell cel51 = new Cell(1, 2).SetHeight(computeValue.computeUnit(8)).SetWidth(computeValue.computeUnit(50)).SetBorderBottom(Border.NO_BORDER).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetTextAlignment(TextAlignment.CENTER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("价税合计(大写)"));Cell cel53 = new Cell(1, 4).SetBorderLeft(Border.NO_BORDER).SetBorderRight(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetHeight(computeValue.computeUnit(8)).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetTextAlignment(TextAlignment.LEFT).Add(new Paragraph(model.jshjdx).SetFont(ST).SetFontSize(10).SetFirstLineIndent(18)).Add(new Image(ImageDataFactory.Create(Path.Combine(model.webHost, "images", "jiashuiheji.png"))).SetWidth(15).SetHeight(15));Cell cel55 = new Cell(1, 1).SetBorderLeft(Border.NO_BORDER).SetBorderRight(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetHeight(computeValue.computeUnit(8)).SetTextAlignment(TextAlignment.RIGHT).Add(new Paragraph("(小写)").SetFont(KT).SetFontSize(9).SetFontColor(customColor));Cell cel54 = new Cell(1, 2).SetBorderLeft(Border.NO_BORDER).SetHeight(computeValue.computeUnit(8)).SetBorderBottom(Border.NO_BORDER).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetTextAlignment(TextAlignment.LEFT).Add(new Paragraph("¥" + model.jshj).SetFont(ST).SetFontSize(10));#region 表尾//添加表格Table endTable = new Table(2, false);Cell cel61 = new Cell(1, 1).SetWidth(computeValue.computeUnit(6)).SetHeight(computeValue.computeUnit(20)).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("备注"));Cell cel62 = new Cell(1, 8).SetTextAlignment(TextAlignment.LEFT).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetWidth(computeValue.computeUnit(195)).SetHeight(computeValue.computeUnit(20)).SetFont(ST).SetFontSize(10).Add(new Paragraph(model.bz));#endregion#region 开票人// 添加发票内容Paragraph ending = new Paragraph().Add("开票人:").SetFont(KT).SetFontSize(9).SetFontColor(customColor).SetTextAlignment(TextAlignment.LEFT);Paragraph endingname = new Paragraph().Add( model.kpr).SetFont(ST).SetFontSize(10).SetTextAlignment(TextAlignment.LEFT);#endregion//循环存放数据int i = 0, j = model.medis.Count;float XJJE=0,XJSE=0,sumh=0,oldsumh=0;float gh = pt + ht + et + kp;bool flag=false;for (i = 0; i < j; i++){//计算每行高度//商品名长度int mcleng =computeValue.GetStrLength(model.medis[i].xmmc)-1;//方法computeValue.GetStrLength()作用为获取字符串长度int ggleng= computeValue.GetStrLength(model.medis[i].ggxh);float higth = (mcleng % 8 == 0 ? mcleng / 8 : mcleng / 8 + 1)>(ggleng % 6 == 0 ? ggleng / 6 : ggleng / 6 + 1)? (mcleng % 8 == 0 ? mcleng / 8 : mcleng / 8 + 1): (ggleng % 6 == 0 ? ggleng / 6 : ggleng / 6 + 1);sumh += higth;Cell cel121 = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetWidth(computeValue.computeUnit(37)).SetHeight(computeValue.computeUnit((float)(higth * 4.375))).SetFont(ST).SetFontSize(10).Add(new Paragraph(model.medis[i].xmmc).SetFixedLeading(12));Cell cel122 = new Cell(1, 2).SetTextAlignment(TextAlignment.LEFT).SetWidth(computeValue.computeUnit(24)).SetHeight(computeValue.computeUnit((float)(higth * 4.375))).SetFont(ST).SetFontSize(10).SetSplitCharacters(new KeepAllSplitCharacters()).Add(new Paragraph(model.medis[i].ggxh).SetFixedLeading(12).SetWidth(computeValue.computeUnit(24)));Cell cel123 = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetWidth(computeValue.computeUnit(12)).SetHeight(computeValue.computeUnit((float)(higth * 4.375))).SetFont(ST).SetFontSize(10).Add(new Paragraph(model.medis[i].dw).SetFixedLeading(12));Cell cel124 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(25)).SetHeight(computeValue.computeUnit((float)(higth * 4.375))).SetFont(ST).SetFontSize(10).Add(new Paragraph(model.medis[i].sl).SetFixedLeading(12));Cell cel125 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(25)).SetHeight(computeValue.computeUnit((float)(higth * 4.375))).SetFont(ST).SetFontSize(10).Add(new Paragraph(model.medis[i].dj).SetFixedLeading(12));Cell cel126 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(26)).SetHeight(computeValue.computeUnit((float)(higth * 4.375))).SetFont(ST).SetFontSize(10).Add(new Paragraph(model.medis[i].je).SetFixedLeading(12));Cell cel127 = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetWidth(computeValue.computeUnit(25)).SetHeight(computeValue.computeUnit((float)(higth * 4.375))).SetFont(ST).SetFontSize(10).Add(new Paragraph(model.medis[i].slv).SetFixedLeading(12));Cell cel128 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(27)).SetHeight(computeValue.computeUnit((float)(higth * 4.375))).SetFont(ST).SetFontSize(10).Add(new Paragraph(model.medis[i].se).SetFixedLeading(12));BodyTable.AddCell(cel121.SetBorder(new SolidBorder(customColor, 1)).SetBorderRight(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER));BodyTable.AddCell(cel122.SetBorder(Border.NO_BORDER));BodyTable.AddCell(cel123.SetBorder(Border.NO_BORDER));BodyTable.AddCell(cel124.SetBorder(Border.NO_BORDER));BodyTable.AddCell(cel125.SetBorder(Border.NO_BORDER));BodyTable.AddCell(cel126.SetBorder(Border.NO_BORDER));BodyTable.AddCell(cel127.SetBorder(Border.NO_BORDER));BodyTable.AddCell(cel128.SetBorder(new SolidBorder(customColor, 1)).SetBorderLeft(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER));BodyTable.StartNewRow();//创建新行// 添加分页//不足一页或刚好一页得情况//小计XJJE += float.Parse(model.medis[i].je);XJSE+= float.Parse(model.medis[i].se);if (sumh <= 35&& i+1==j){//中间高度float nh = 140 - gh + 25;//有分页的情况if (flag){//中间高度加8//小计Cell cel411 = new Cell(1, 2).SetTextAlignment(TextAlignment.CENTER).SetHeight(computeValue.computeUnit(4.5f)).SetFont(KT).SetFontSize(9).SetFontColor(customColor).SetPaddingBottom(-5).Add(new Paragraph("小\t\t计").SetFixedLeading(11));Cell cel421 = new Cell(1, 5).SetBorder(Border.NO_BORDER).SetTextAlignment(TextAlignment.RIGHT).SetHeight(computeValue.computeUnit(4.5f)).SetFont(ST).SetFontSize(9).Add(new Paragraph("¥" + XJJE).SetFixedLeading(11));Cell cel431 = new Cell(1, 2).SetTextAlignment(TextAlignment.RIGHT).SetHeight(computeValue.computeUnit(4.5f)).SetFont(ST).SetFontSize(9).Add(new Paragraph("¥" + XJSE).SetFixedLeading(11));//合计小计列BodyTable.AddCell(cel411.SetBorder(new SolidBorder(customColor, 1)).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER).SetBorderRight(Border.NO_BORDER));BodyTable.AddCell(cel421.SetBorder(Border.NO_BORDER));BodyTable.AddCell(cel431.SetBorder(new SolidBorder(customColor, 1)).SetBorderLeft(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER));BodyTable.StartNewRow();}//不够一页的情况//合计列BodyTable.AddCell(cel41.SetBorder(new SolidBorder(customColor, 1)).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER).SetBorderRight(Border.NO_BORDER));BodyTable.AddCell(cel42.SetBorder(Border.NO_BORDER));BodyTable.AddCell(cel43.SetBorder(new SolidBorder(customColor, 1)).SetBorderLeft(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER));BodyTable.StartNewRow();//新增行//价税合计大小写BodyTable.AddCell(cel51.SetBorder(new SolidBorder(customColor, 1)));//BodyTable.AddCell(cel52.SetBorder(new SolidBorder(customColor, 1)));BodyTable.AddCell(cel53.SetBorder(new SolidBorder(customColor, 1)));BodyTable.AddCell(cel55.SetBorder(new SolidBorder(customColor, 1)));BodyTable.AddCell(cel54.SetBorder(new SolidBorder(customColor, 1)));BodyTable.StartNewRow();//新增行float lasth=0;if (sumh <= 8){lasth = 8-sumh;}else if (sumh <= 12){nh += 17.5f*1;lasth = 12 - sumh;}else if (sumh <= 16){nh += 17.5f * 2;lasth = 16 - sumh;}else if (sumh <= 20){nh += 17.5f * 3;lasth = 20 - sumh;}else if (sumh <= 24){nh += 17.5f * 4;lasth = 24 - sumh;}else if (sumh <= 28){nh += 17.5f * 5;lasth = 28 - sumh;}else if (sumh <= 32){nh += 17.5f * 6;lasth = 32 - sumh;}else if (sumh <= 36){nh += 17.5f * 7;lasth = 36 - sumh;}else if (sumh <= 40){nh += 17.5f * 8;lasth = 40 - sumh;}//设置最后一行行高,因为不足一页时,最后一行可能需要占用多行行高var bzh = computeValue.computeUnit((higth + lasth) * 4.375f);cel121.SetHeight(bzh);cel122.SetHeight(bzh);cel123.SetHeight(bzh);cel124.SetHeight(bzh);cel125.SetHeight(bzh);cel126.SetHeight(bzh);cel127.SetHeight(bzh);cel128.SetHeight(bzh);BodyTable.SetHeight(computeValue.computeUnit(nh));//给表设置高度document.Add(BodyTable.SetFixedPosition(computeValue.computeUnit(4.5f), computeValue.computeUnit(243- nh) , computeValue.computeUnit(201)));//表尾备注endTable.AddCell(cel61.SetBorder(new SolidBorder(customColor, 1)));endTable.AddCell(cel62.SetBorder(new SolidBorder(customColor, 1)));float b = computeValue.computeUnit(241 - 20- nh) ;document.Add(endTable.SetFixedPosition(computeValue.computeUnit(4.5f), b, computeValue.computeUnit(201)));//价税合计图片//document.Add(img.SetFixedPosition(computeValue.computeUnit(51.5f), b + computeValue.computeUnit(24)));//开票人document.Add(ending.SetFixedPosition(computeValue.computeUnit(18), b - computeValue.computeUnit((float)8.5), computeValue.computeUnit(183)));document.Add(endingname.SetFixedPosition(computeValue.computeUnit(29), b - computeValue.computeUnit((float)8.5), computeValue.computeUnit(183)));sumh = 0;}//分页的情况else if (((sumh-higth >= 36) && (sumh - higth <= 39)&& i != 0 && i + 1 != j)|| (sumh>= 33)&& i + 2 == j){//小计Cell cel411 = new Cell(1, 2).SetTextAlignment(TextAlignment.CENTER).SetHeight(computeValue.computeUnit(4.5f)).SetFont(KT).SetFontSize(9).SetFontColor(customColor).SetPaddingBottom(-5).Add(new Paragraph("小\t\t计").SetFixedLeading(11));Cell cel421 = new Cell(1, 5).SetBorder(Border.NO_BORDER).SetTextAlignment(TextAlignment.RIGHT).SetHeight(computeValue.computeUnit(4.5f)).SetFont(ST).SetFontSize(9).Add(new Paragraph("¥" + XJJE).SetFixedLeading(11));Cell cel431 = new Cell(1, 2).SetTextAlignment(TextAlignment.RIGHT).SetHeight(computeValue.computeUnit(4.5f)).SetFont(ST).SetFontSize(9).Add(new Paragraph("¥" +XJSE).SetFixedLeading(11));//合计小计列BodyTable.AddCell(cel411.SetBorder(new SolidBorder(customColor, 1)).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER).SetBorderRight(Border.NO_BORDER));BodyTable.AddCell(cel421.SetBorder(Border.NO_BORDER));BodyTable.AddCell(cel431.SetBorder(new SolidBorder(customColor, 1)).SetBorderLeft(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER));BodyTable.StartNewRow();BodyTable.AddCell(cel41.SetBorder(new SolidBorder(customColor, 1)).SetBorderTop(Border.NO_BORDER).SetBorderRight(Border.NO_BORDER));BodyTable.AddCell(cel42.SetBorder(new SolidBorder(customColor, 1)).SetBorderLeft(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER).SetBorderRight(Border.NO_BORDER));BodyTable.AddCell(cel43.SetBorder(new SolidBorder(customColor, 1)).SetBorderLeft(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER));BodyTable.StartNewRow();//float nh =(sumh-oldsumh)*4.375f+13.5f+38;//判断中间列表占用高度--> i * computeValue.computeUnit(10):每行数据的高度;+ computeValue.computeUnit(10):表头高度+合计行的高度;(i*15):每行数据的行间距float nh = (sumh) * 4.375f + 13.5f + 38;BodyTable.SetHeight(computeValue.computeUnit(nh));BodyTable.SetBorderBottom(new SolidBorder(customColor, 1));document.Add(BodyTable.SetFixedPosition(computeValue.computeUnit(4.5f), computeValue.computeUnit(243- nh) , computeValue.computeUnit(201)));//开票人document.Add(ending.SetFixedPosition(computeValue.computeUnit(18), computeValue.computeUnit(243- nh- 9) , computeValue.computeUnit(183)));document.Add(endingname.SetFixedPosition(computeValue.computeUnit(29), computeValue.computeUnit(243- nh- 9) , computeValue.computeUnit(183)));//分页document.Add(new AreaBreak());BodyTable = new Table(9, false);#region 表头Cell cel110 = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetWidth(computeValue.computeUnit(37)).SetHeight(computeValue.computeUnit(4.5f)).SetBorderRight(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("项目名称"));Cell cel120 = new Cell(1, 2).SetTextAlignment(TextAlignment.LEFT).SetWidth(computeValue.computeUnit(24)).SetBorder(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("规格型号"));Cell cel130 = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetWidth(computeValue.computeUnit(12)).SetBorder(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("单位"));Cell cel140 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(25)).SetBorder(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("数量"));Cell cel150 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(25)).SetBorder(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("单价"));Cell cel160 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(26)).SetBorder(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("金额"));Cell cel170 = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetBorder(Border.NO_BORDER).SetWidth(computeValue.computeUnit(25)).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("税率/征收率"));Cell cel180 = new Cell(1, 1).SetTextAlignment(TextAlignment.RIGHT).SetWidth(computeValue.computeUnit(27)).SetBorderLeft(Border.NO_BORDER).SetBorderBottom(Border.NO_BORDER).SetBorderTop(Border.NO_BORDER).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Paragraph("税额"));BodyTable.AddCell(cel110.SetBorder(new SolidBorder(customColor, 1)));BodyTable.AddCell(cel120);BodyTable.AddCell(cel130);BodyTable.AddCell(cel140);BodyTable.AddCell(cel150);BodyTable.AddCell(cel160);BodyTable.AddCell(cel170);BodyTable.AddCell(cel180.SetBorder(new SolidBorder(customColor, 1)));BodyTable.StartNewRow();#endregionXJJE = 0; XJSE = 0;//oldsumh = sumh;sumh = 0;flag = true;continue;}//添加页码int n=pdf.GetNumberOfPages();if (n>1){for (int p = 2; p <= n; p++){document.ShowTextAligned(new Paragraph(String.Format("共" + n + "页 第" + p+"页")).SetFontSize(10).SetFont(ST),computeValue.computeUnit(200), computeValue.computeUnit(272), p, TextAlignment.RIGHT,VerticalAlignment.TOP, 0);}}// 关闭文档document.Close();Console.WriteLine("PDF发票已生成:" + outputPath);}}catch (Exception e){Console.WriteLine(e.Message);throw;}}/// <summary>
/// 金额转换成中文大写金额
/// </summary>
/// <param name="LowerMoney">eg:10.74</param>
/// <returns></returns>
private static string MoneyToUpper(string LowerMoney)
{string functionReturnValue = null;bool IsNegative = false; // 是否是负数if (LowerMoney.Trim().Substring(0, 1) == "-"){// 是负数则先转为正数LowerMoney = LowerMoney.Trim().Remove(0, 1);IsNegative = true;}string strLower = null;string strUpart = null;string strUpper = null;int iTemp = 0;// 保留两位小数 123.489→123.49  123.4→123.4LowerMoney = Math.Round(double.Parse(LowerMoney), 2).ToString();if (LowerMoney.IndexOf(".") > 0){if (LowerMoney.IndexOf(".") == LowerMoney.Length - 2){LowerMoney = LowerMoney + "0";}}else{LowerMoney = LowerMoney + ".00";}strLower = LowerMoney;iTemp = 1;strUpper = "";while (iTemp <= strLower.Length){switch (strLower.Substring(strLower.Length - iTemp, 1)){case ".":strUpart = "圆";break;case "0":strUpart = "零";break;case "1":strUpart = "壹";break;case "2":strUpart = "贰";break;case "3":strUpart = "叁";break;case "4":strUpart = "肆";break;case "5":strUpart = "伍";break;case "6":strUpart = "陆";break;case "7":strUpart = "柒";break;case "8":strUpart = "捌";break;case "9":strUpart = "玖";break;}switch (iTemp){case 1:strUpart = strUpart + "分";break;case 2:strUpart = strUpart + "角";break;case 3:strUpart = strUpart + "";break;case 4:strUpart = strUpart + "";break;case 5:strUpart = strUpart + "拾";break;case 6:strUpart = strUpart + "佰";break;case 7:strUpart = strUpart + "仟";break;case 8:strUpart = strUpart + "万";break;case 9:strUpart = strUpart + "拾";break;case 10:strUpart = strUpart + "佰";break;case 11:strUpart = strUpart + "仟";break;case 12:strUpart = strUpart + "亿";break;case 13:strUpart = strUpart + "拾";break;case 14:strUpart = strUpart + "佰";break;case 15:strUpart = strUpart + "仟";break;case 16:strUpart = strUpart + "万";break;default:strUpart = strUpart + "";break;}strUpper = strUpart + strUpper;iTemp = iTemp + 1;}strUpper = strUpper.Replace("零拾", "零");strUpper = strUpper.Replace("零佰", "零");strUpper = strUpper.Replace("零仟", "零");strUpper = strUpper.Replace("零零零", "零");strUpper = strUpper.Replace("零零", "零");strUpper = strUpper.Replace("零角零分", "整");strUpper = strUpper.Replace("零分", "整");strUpper = strUpper.Replace("零角", "零");strUpper = strUpper.Replace("零亿零万零圆", "亿圆");strUpper = strUpper.Replace("亿零万零圆", "亿圆");strUpper = strUpper.Replace("零亿零万", "亿");strUpper = strUpper.Replace("零万零圆", "万圆");strUpper = strUpper.Replace("零亿", "亿");strUpper = strUpper.Replace("零万", "万");strUpper = strUpper.Replace("零圆", "圆");strUpper = strUpper.Replace("零零", "零");Console.WriteLine("零角零分");// 对壹圆以下的金额的处理if (strUpper.Substring(0, 1) == "圆"){strUpper = strUpper.Substring(1, strUpper.Length - 1);}if (strUpper.Substring(0, 1) == "零"){strUpper = strUpper.Substring(1, strUpper.Length - 1);}if (strUpper.Substring(0, 1) == "角"){strUpper = strUpper.Substring(1, strUpper.Length - 1);}if (strUpper.Substring(0, 1) == "分"){strUpper = strUpper.Substring(1, strUpper.Length - 1);}if (strUpper.Substring(0, 1) == "整"){strUpper = "零圆整";}functionReturnValue = strUpper;if (IsNegative == true){return "负" + functionReturnValue;}else{return string.Format(functionReturnValue, Encoding.GetEncoding("GB2312"));}
}public class ComputeValue
{/// <summary>/// 毫米转换磅/// </summary>/// <param name="millimetre"></param>/// <returns></returns>public float computeUnit(float millimetre){return millimetre / 10 / 2.54f * 72;}/// <summary>/// 获取字符串长度/// </summary>/// <param name="str"></param>/// <returns></returns>public int GetStrLength(string str){double length = 0;str = str.Replace(" ", "");for (int i = 0; i < str.Length; i++) {if (str[i] >= 0x4E00 && str[i] <= 0x9FA5){length += 1;}else{length += 0.5;}}return (int)Math.Ceiling(length);}
}

步骤二:创建PdfEventHandler类:

/// <summary>
/// 需要继承IEventHandler
/// </summary>
public class PdfEventHandler : IEventHandler
{private NaturalSystemPdfModel _model;private PdfFont KT;private PdfFont ST;private PdfFont CN;//构造方法:带入模型以及字体public PdfEventHandler(NaturalSystemPdfModel model, PdfFont kt, PdfFont st, PdfFont cn) {_model = model;KT = kt;ST = st;CN = cn;}public void HandleEvent(Event e){PdfDocumentEvent docEvent = (PdfDocumentEvent)e;PdfDocument pdfDoc = docEvent.GetDocument();PdfPage page = docEvent.GetPage();PdfCanvas pdfCanvas = new PdfCanvas(page.NewContentStreamBefore(), page.GetResources(), pdfDoc);Rectangle pageSize = page.GetPageSize();ComputeValue computeValue = new ComputeValue();// 定义自定义RGB颜色(例如,红色)DeviceRgb customColor = new DeviceRgb(128, 0, 0);Canvas canvas = new Canvas(pdfCanvas, pageSize);#region 票头#region 双横线//添加横线pdfCanvas.MoveTo(computeValue.computeUnit(141), computeValue.computeUnit(278.5f));pdfCanvas.LineTo(computeValue.computeUnit(69), computeValue.computeUnit(278.5f));pdfCanvas.SetStrokeColor(new DeviceRgb(128, 0, 0));pdfCanvas.MoveTo(computeValue.computeUnit(141), computeValue.computeUnit(277.5f));pdfCanvas.LineTo(computeValue.computeUnit(69), computeValue.computeUnit(277.5f));pdfCanvas.SetStrokeColor(new DeviceRgb(128, 0, 0));pdfCanvas.ClosePathStroke();#endregion#region 票头左边 二维码、标签码// 添加动态二维码Image EWM = new Image(ImageDataFactory.Create(_model.qrCode)).SetWidth(computeValue.computeUnit(20)).SetHeight(computeValue.computeUnit(20));canvas.Add(EWM.SetFixedPosition(1, computeValue.computeUnit(7), computeValue.computeUnit(271)));//二维码中间的“税”字图标Image S = new Image(ImageDataFactory.Create(System.IO.Path.Combine(_model.webHost, "images", "Shui.png"))).SetWidth(computeValue.computeUnit(4)).SetHeight(computeValue.computeUnit(4));canvas.Add(S.SetFixedPosition(1, computeValue.computeUnit(15), computeValue.computeUnit((float)279)));//Image EWM = new BarcodeQRCode("", 54, 56, null);//添加标签//Image BQM = new Image(ImageDataFactory.Create("E://111.png"))//    .SetWidth(computeValue.computeUnit(28))//    .SetHeight(computeValue.computeUnit(20));//canvas.Add(BQM.SetFixedPosition(1, computeValue.computeUnit(29), computeValue.computeUnit(271)));#endregion#region 票头文字及印章// 添加发票内容Paragraph heading = new Paragraph(_model.type).SetTextAlignment(TextAlignment.CENTER).SetFont(KT).SetFontColor(customColor).SetFontSize(19);if (_model.type.Contains("增值税")){canvas.Add(heading.SetFixedPosition(computeValue.computeUnit(56), computeValue.computeUnit(280.35f), computeValue.computeUnit(100)));}else {canvas.Add(heading.SetFixedPosition(computeValue.computeUnit(72), computeValue.computeUnit(280.35f), computeValue.computeUnit(70)));}// 添加发票章图片./Images/fapiaozhang.pngImage stamp = new Image(ImageDataFactory.Create(System.IO.Path.Combine(_model.webHost, "images", "fapiaozhang.png"))).SetWidth(computeValue.computeUnit(28)).SetHeight(computeValue.computeUnit(20));canvas.Add(stamp.SetFixedPosition(1, computeValue.computeUnit(92), computeValue.computeUnit(269)));#endregion#region 票头右上角信息// 发票号码:Paragraph invoiceInfo_Num = new Paragraph().Add("发票号码:").SetFont(KT).SetFontSize(9).SetFontColor(customColor).SetTextAlignment(TextAlignment.LEFT);canvas.Add(invoiceInfo_Num.SetFixedPosition(computeValue.computeUnit(155), computeValue.computeUnit(280.65f), computeValue.computeUnit(19.06f)));Paragraph invoiceInfo_Numc = new Paragraph().Add(_model.fphm).SetFont(ST).SetFontSize(9).SetTextAlignment(TextAlignment.LEFT);canvas.Add(invoiceInfo_Numc.SetFixedPosition(computeValue.computeUnit(170), computeValue.computeUnit(280.65f), computeValue.computeUnit(33.36f)));// 开票日期:Paragraph invoiceInfo_Date = new Paragraph().Add("开票日期: ").SetFont(KT).SetFontSize(9).SetFontColor(customColor).SetTextAlignment(TextAlignment.LEFT);canvas.Add(invoiceInfo_Date.SetFixedPosition(computeValue.computeUnit(155), computeValue.computeUnit(274.5f), computeValue.computeUnit(19.06f)));Paragraph invoiceInfo_Datec = new Paragraph().Add(_model.kprq.ToString("yyyy年MM月dd日")).SetFont(ST).SetFontSize(9).SetTextAlignment(TextAlignment.LEFT);canvas.Add(invoiceInfo_Datec.SetFixedPosition(computeValue.computeUnit(170), computeValue.computeUnit(274.5f), computeValue.computeUnit(33.36f)));#endregion#endregion#region 购买方信息//添加表格Table HeadTable = new Table(4, false);Cell cel01 = new Cell(1, 1).SetTextAlignment((TextAlignment)TextAlignment.CENTER).SetWidth(computeValue.computeUnit(6)).SetHeight(computeValue.computeUnit(22)).Add(new Paragraph("购买方信息").SetFixedLeading(12).SetFontColor(customColor).SetFont(KT).SetFontSize(9).SetFontColor(customColor));Cell cel02 = new Cell(1, 1).SetTextAlignment(TextAlignment.LEFT).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetWidth(computeValue.computeUnit(94.5f)).SetHeight(computeValue.computeUnit(22)).Add(new Paragraph("名称:").SetFontColor(customColor).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Text(_model.gmfmc).SetFontSize(10).SetFont(ST).SetFontColor(ColorConstants.BLACK))).Add(new Paragraph("统一社会信用代码/纳税人识别号:").SetFontColor(customColor).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Text(_model.gmfnsrsbh).SetFontSize(10).SetFont(ST).SetFontColor(ColorConstants.BLACK)));Cell cel03 = new Cell(1, 1).SetTextAlignment(TextAlignment.CENTER).SetWidth(computeValue.computeUnit(6)).SetHeight(computeValue.computeUnit(22)).Add(new Paragraph("销售方信息").SetFixedLeading(12).SetFontColor(customColor).SetFont(KT).SetFontSize(9).SetFontColor(customColor));Cell cel04 = new Cell(1, 1).SetTextAlignment(TextAlignment.LEFT).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetWidth(computeValue.computeUnit(94.5f)).SetHeight(computeValue.computeUnit(22)).Add(new Paragraph("名称:").SetFontColor(customColor).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Text(_model.xsfmc).SetFontSize(10).SetFont(ST).SetFontColor(ColorConstants.BLACK))).Add(new Paragraph("统一社会信用代码/纳税人识别号:").SetFontColor(customColor).SetFont(KT).SetFontSize(9).SetFontColor(customColor).Add(new Text(_model.xsfnsrsbh).SetFontSize(10).SetFont(ST).SetFontColor(ColorConstants.BLACK)));HeadTable.AddCell(cel01.SetBorder(new SolidBorder(customColor, 1)));HeadTable.AddCell(cel02.SetBorder(new SolidBorder(customColor, 1)));HeadTable.AddCell(cel03.SetBorder(new SolidBorder(customColor, 1)));HeadTable.AddCell(cel04.SetBorder(new SolidBorder(customColor, 1)));canvas.Add(HeadTable.SetFixedPosition(computeValue.computeUnit(4.5f), computeValue.computeUnit(243), computeValue.computeUnit(201)));#endregion// 添加页脚页码//if (pdfDoc.GetNumberOfPages() > 1)//{//    #region 页眉//    Paragraph p = new Paragraph("共" + pdfDoc.GetNumberOfPages() + "页 第" + pdfDoc.GetPageNumber(page) + "页")//    .SetFontSize(9)//    .SetFont(ST)//    .SetFixedPosition(computeValue.computeUnit(186), computeValue.computeUnit(266.5f), computeValue.computeUnit(141));//    canvas.Add(p);//    #endregion//}//canvas.Add(p);canvas.Close();}
}

完成!(创作不易,点赞鼓励_

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/26980.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

我们一起聊聊 Go 性能工具

从开发到部署的整个过程都离不开基本的负载测试和性能剖析。利用 Go 的 pprof 和跟踪工具&#xff0c;开发人员可以深入了解性能瓶颈、CPU 使用率和内存分配情况。 在开发过程中&#xff0c;从一开始到应用程序的推出都充满了挑战&#xff0c;而负载测试则是其中至关重要的一项…

Kettle 数据抽取工具使用教程:从入门到实战

一、简介 Kettle 是 Pentaho Data Integration (PDI) 的一个组成部分&#xff0c;是一个开源的数据集成工具。它被广泛用于数据的抽取、转换和加载 (ETL) 过程。Kettle 提供了一个易于使用的图形界面&#xff0c;可以轻松设计和执行 ETL 流程。 github 源码地址&#xff1a;ht…

postman教程-19-mock测试

上一小节我们学习了Postman接口参数化方法&#xff0c;本小节我们讲解一下Postman mock测试的方法。 一、什么叫mock测试 mock测试就是在测试过程中&#xff0c;对某些不容易构造或者不容易获取的对象&#xff0c;用一个虚拟的对象来创建以便于测试的一种测试方法&#xff0c…

chatgpt 生成的 左侧导航功能的网页

目录 一、左侧导航 1、效果如下&#xff1a; 2、代码如下&#xff1a; 3、技术点&#xff1a; 1)、箭头居中 2)、导航区域 3)、导航隐藏时&#xff0c;正文重新居中 4)、设置视口高度 这是用chatgpt生成的网页&#xff0c;其实&#xff0c;不是一下子就生成了满足需求的…

Syncovery:跨平台高效文件备份与同步的得力助手

在数字化时代&#xff0c;数据安全与文件同步已成为个人及企业不可或缺的需求。Syncovery作为一款专为Mac和Windows用户设计的文件备份和同步工具&#xff0c;凭借其高效、安全和易用的特点&#xff0c;赢得了广泛赞誉。 一、强大备份功能 Syncovery支持多种备份方案和数据格…

LeetCode 119.杨辉三角 II

1.题目要求如图所示: 示例 1:输入: rowIndex 3 输出: [1,3,3,1]示例 2:输入: rowIndex 0 输出: [1]示例 3:输入: rowIndex 1 输出: [1,1]先用malloc函数创造一个二维数组&#xff0c;变成杨辉三角&#xff0c;然后再用一维数组找到所指的那一行: /*** Note: The returned…

java使用多线程导出数据至excel

大量数据导出 问题 如果数据量较大&#xff0c;那么使用 Apache POI 导出数据可能会导致OOM或者到处时间较长。 解决方案 使用多线程同时导出多个excel&#xff0c;缩短接口响应时间 代码示例 public void test () {List<Test> tests testMapper.selectAll(); // 查…

labelme安装(通过anaconda)

1.下载安装anaconda 2.安装完成后打开&#xff0c;在环境页里面创建环境 选择3.6.13版本&#xff0c;然后运行 3.安装labelme pip install labelme -i https://pypi.tuna.tsinghua.edu.cn/simple 使用上面命令加速一下 4.labelme打开并标注 总结&#xff1a;现在版本越来越多…

中小学一级教师相当于什么级别的职称

你知道吗&#xff1f;当你一步步攀登职称的阶梯&#xff0c;达到中小学一级教师的荣誉时&#xff0c;你究竟站在了哪个高度&#xff1f;一级教师不仅是一个职称的标签&#xff0c;更是对你专业能力的认可。 中小学教师的职称体系&#xff0c;就像一幅层次分明的画卷&#xff0c…

Blender:渲染输出

渲染输出界面 渲染设置界面&#xff1a; 输出设置界面&#xff1a; 输出文件格式 【文档】 视频导出格式&#xff1a; AVI JPEG 使用JPEG压缩的AVI。有损&#xff0c;能得到更小的文件&#xff0c;但大小无法与编解码器的压缩算法得到的文件相比。JPEG 压缩也是数字摄像机使用…

知识图谱的应用---新零售

文章目录 新零售知识图谱构建过程典型应用 新零售 新零售&#xff0c;即个人、企业以互联网为依托&#xff0c;通过运用大数据、人工智能等先进技术手段并运用心理学知识&#xff0c;对商品的生产、流通与销售过程进行升级改造&#xff0c;进而重塑业态结构与生态圈&#xff0c…

精准定位,智慧提纯:高级数据提取策略

在数据驱动的时代&#xff0c;高级数据提取策略成为企业决策、科学研究以及各类项目成功的关键。数据提取&#xff0c;不仅仅是简单地收集信息&#xff0c;而是需要精准定位目标数据&#xff0c;并通过智慧提纯方法&#xff0c;从海量数据中提取出有价值、有深度的信息。本文将…

Redis之线程IO模型

引言 Redis是个单线程程序&#xff01;这点必须铭记。除了Redis之外&#xff0c;Node.js也是单线程&#xff0c;Nginx也是单线程&#xff0c;但是他们都是服务器高性能的典范。 Redis单线程为什么能够这么快&#xff01; 因为他所有的数据都在内存中&#xff0c;所有的运算都…

【制作100个unity游戏之29】使用unity复刻经典游戏《愤怒的小鸟》(完结,附带项目源码)

最终效果 文章目录 最终效果前言素材下载简单搭建环境控制小鸟生成弹簧 限制小鸟的控制范围弹簧线的显示隐藏飞行新增木头木头销毁不同血量的木头状态配置更多物品爆炸效果创建敌人的小猪创建多个小鸟循环游戏结束相机跟随加分特效不同定义技能的鸟加速鸟回旋鸟爆炸鸟效果 轨迹…

小学生作文辅导杂志小学生作文辅导杂志社小学生作文辅导编辑部2024年第2期目录

写法导引 创意引航&#xff0c;笔墨生辉——小学语文习作教学中的创新思维训练 杜娟; 3-5 陶行知“小先生制”教育思想在小学作文练习中的应用探索 张淑勤; 6-8 新课程标准视域下小学语文习作教学策略探析 任真真; 9-11 即时作文&#xff1a;开辟小学习作教学的…

Spring Boot集成 Spring Retry 实现容错重试机制并附源码

&#x1f604; 19年之后由于某些原因断更了三年&#xff0c;23年重新扬帆起航&#xff0c;推出更多优质博文&#xff0c;希望大家多多支持&#xff5e; &#x1f337; 古之立大事者&#xff0c;不惟有超世之才&#xff0c;亦必有坚忍不拔之志 &#x1f390; 个人CSND主页——Mi…

MATLAB神经网络---激活层

非线性变换的目的 非线性变换的目的是为神经网络引入一些非线性特征&#xff0c;使其训练出一些符合各种曲线或各种特征的模型。 换句话来说&#xff0c;如果模型都是直线特征的话&#xff0c;它的泛化能力会不够好。 目录 深度学习层列表 - MATLAB & Simulink - MathWo…

初识MySQL数据库

目录 一、了解数据库 1.数据库的相关概念 2.数据库系统发展史 3.主流数据库产品 二、数据库分类 1.关系数据库 2.非关系型数据库 三、mysql的yum安装与源码编译安装 1.源码编译安装mysql 2.yum安装 mysql5.7 四、MySQL数据类型 1.常用的数据类型 五、查看数据库…

高性能8位单片机 CA51M151,1T 8051内核 / 内置12位ADC / 16 位PWM / 支持触摸 / 8K MTP

CA51M151 系列芯片是基于 1T 8051 内核的 8 位微控制器&#xff0c;不仅保留了传统 8051 芯片的基本特性&#xff0c;通常情况下运行速度比传统的 8051 芯片快 10 倍&#xff0c;性能更加优越。芯片内置 8 KB MTP 程序存储器&#xff0c;256Byte 内部RAM&#xff0c;512Byte 外…

持绪电商:开一家抖音网店大概多久才能做起来

在数字化浪潮的推动下&#xff0c;抖音不仅是年轻人喜爱的短视频平台&#xff0c;更成为电商的新阵地。不少创业者和品牌纷纷入驻&#xff0c;希望能借力抖音的流量红利实现快速成长。但开设一家抖音网店并使其蓬勃发展&#xff0c;并非一朝一夕之事&#xff0c;它需要策略、耐…