用 的itextsharp 5.5.4,不知道图片类型的页眉应该怎么加,见代码
MemoryStream outputStream = new MemoryStream();//要把PDF写到哪个串流 byte[] data = Encoding.UTF8.GetBytes(htmlText);//字串转成byte[] MemoryStream msInput = new MemoryStream(data); Document doc = new Document();//要写PDF的文件,建构子没填的话预设直式A4 PdfWriter writer = PdfWriter.GetInstance(doc, outputStream); //指定文件预设开档时的缩放为100% PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 1f); //Rectangle rect = new Rectangle(36, 54, 559, 788); //writer.SetBoxSize("art", rect); HeaderFooter header = new HeaderFooter(); writer.PageEvent = header; //开启Document文件 doc.Open(); //HeaderFooter.PAGE_NUMBER = true; //使用XMLWorkerHelper把Html parse到PDF档里 XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, msInput, null, Encoding.UTF8, new UnicodeFontFactory()); //将pdfDest设定的资料写到PDF档 PdfAction action = PdfAction.GotoLocalPage(1, pdfDest, writer); writer.SetOpenAction(action); // 重置页面数量 doc.ResetPageCount(); doc.Close(); msInput.Close(); outputStream.Close();
通过writer直接画
大神,wirte怎么画?有例子么?参考一下啊
通过模板