没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:胡涛|2022-02-28 09:48:20.750|阅读 566 次
概述:为方便使用者快速掌握和了解Spire.PDF,本文列举了PDF理控件Spire.pdf常见问题及解答欢迎下载最新版体验!
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
为方便使用者快速掌握和了解Spire.PDF,本文列举了PDF理控件Spire.pdf常见问题及解答欢迎下载最新版体验!
A:Spire.PDF 无法加载包含 html 代码的字符串。但是 Spire.Doc 可以加载它并且 Spire.Doc 支持 PDF 格式。所以你可以使用 Spire.Doc 来完成这项工作。完整代码:
string htmlstring = "<!DOCTYPE html><html><body><h1>Header 1</h1><p>First paragraph</p></body></html>"; Document doc = new Document(); Section sec = doc.AddSection(); Paragraph para = sec.AddParagraph(); //add html code to document para.AppendHTML(htmlstring); //save document as PDF format doc.SaveToFile("result.pdf", FileFormat.PDF);
A:表格是一个更简单的网格。在网格中,您可以操作每个单元格,为每个单元格设置不同的样式并嵌入另一个网格。所以你可以使用网格来完成这项工作。完整代码:
PdfDocument document = new PdfDocument(); PdfPageBase page = document.Pages.Add(PdfPageSize.A4); PdfGrid grid = new PdfGrid(); grid.Columns.Add(1); grid.Columns[0].Width = page.Canvas.ClientSize.Width; PdfGridRow row0 = grid.Rows.Add(); row0.Cells[0].Value = "This is the first row."; row0.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); PdfGridRow row1 = grid.Rows.Add(); PdfLayoutResult result=grid.Draw(page, new PointF(0, 20)); PdfGrid grid2 = new PdfGrid(); grid2.Columns.Add(2); PdfGridRow newrow = grid2.Rows.Add(); grid2.Columns[0].Width = grid.Columns[0].Width / 2; grid2.Columns[1].Width = grid.Columns[0].Width / 2; newrow.Cells[0].Value = "This is row two column one."; newrow.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); newrow.Cells[1].Value = "This is row two column two."; newrow.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); //assign grid2 to row1 row1.Cells[0].Value = grid2; //drwa grid2 result = grid2.Draw(page, new PointF(0, result.Bounds.Location.Y + result.Bounds.Height)); document.SaveToFile("result.pdf");
A:Spire.PDF 为您提供名为 RowSpan 和 ColumnSpan 的属性来合并单元格。完整代码:
PdfDocument doc = new PdfDocument(); PdfPageBase page = doc.Pages.Add(); PdfGrid grid = new PdfGrid(); grid.Columns.Add(5); float width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1); for (int i = 0; i < grid.Columns.Count; i++) { grid.Columns[i].Width = width * 0.20f; } PdfGridRow row0 = grid.Rows.Add(); PdfGridRow row1 = grid.Rows.Add(); row0.Style.Font = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Bold), true); row1.Style.Font = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Italic), true); row0.Cells[0].Value = "Corporation"; //merge with the downside cell row0.Cells[0].RowSpan = 2; row0.Cells[1].Value = "B&K Undersea Photo"; row0.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); //merge with the right cell row0.Cells[1].ColumnSpan = 3; row0.Cells[4].Value = "World"; row0.Cells[4].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Bold | FontStyle.Italic), true); row0.Cells[4].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); row0.Cells[4].Style.BackgroundBrush = PdfBrushes.LightGreen; row1.Cells[1].Value = "Diving International Unlimited"; row1.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); row1.Cells[1].ColumnSpan = 4; grid.Draw(page, new PointF(0, 0)); doc.SaveToFile("result.pdf");
A:首先,使用类 PdfCertificate 创建一个证书实例。证书实例将用于创建 PdfSignature 实例。然后使用类 PdfSignature 创建一个签名实例。并且您需要设置签名实例的属性。完整代码:
PdfDocument doc = new PdfDocument(); doc.LoadFromFile("sample.pdf"); PdfCertificate cert = new PdfCertificate("Demo.pfx", "e-iceblue"); //add signature to every page of PDF file foreach (PdfPageBase page in doc.Pages) { PdfSignature signature = new PdfSignature(page.Document, page, cert, "demo"); signature.ContactInfo = "Harry"; signature.Certificated = true; signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill; } doc.SaveToFile("result.pdf");
A : 请调用 ReArrange 方法。该方法将一个 int 数组作为参数。int 数组表示页面的新顺序。完整代码:
PdfDocument document = new PdfDocument(); //sample.pdf has four pages document.LoadFromFile("sample.pdf"); //rearrange the pages of the PDF file int[] range = new int[] { 0, 2, 1, 3 }; document.Pages.ReArrange(range); document.SaveToFile("result.pdf");
A : Spire.PDF 不直接支持图片水印。但是您可以将图像设置为 BackgroundImage。如果图像足够大,BackgroundImage 就像图像水印一样。完整代码:
PdfDocument document = new PdfDocument(); PdfPageBase page = document.Pages.Add(PdfPageSize.A4); page.Canvas.DrawString("This is a demo about image watermark!", new PdfFont(PdfFontFamily.Helvetica, 25f), new PdfSolidBrush(Color.Green), 10, 40); //set image as BackgroundImage to make image watermark Image img = Image.FromFile("scene.bmp"); page.BackgroundImage = img; document.SaveToFile("result.pdf");
A : PdfDocumentTemplate 中的内容将适用于 PDF 文件的每一页。您所要做的就是创建一个将标题添加到 PdfDocumentTemplate 的方法。然后标题将添加到每个页面。完整代码:
static void Main(string[] args) { PdfDocument doc = new PdfDocument(); PdfUnitConvertor unitCvtr = new PdfUnitConvertor(); PdfMargins margin = new PdfMargins(); margin.Top = unitCvtr.ConvertUnits(3.0f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point); margin.Bottom = margin.Top; margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point); margin.Right = margin.Left; // create three page PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, margin); page = doc.Pages.Add(PdfPageSize.A4, margin); page = doc.Pages.Add(PdfPageSize.A4, margin); //apply template SetDocumentTemplate(doc, PdfPageSize.A4, margin); doc.SaveToFile("result.pdf"); } //method to add header to every page private static void SetDocumentTemplate(PdfDocument doc, SizeF pageSize, PdfMargins margin) { PdfPageTemplateElement leftSpace = new PdfPageTemplateElement(margin.Left, pageSize.Height); doc.Template.Left = leftSpace; PdfPageTemplateElement topSpace = new PdfPageTemplateElement(pageSize.Width, margin.Top); topSpace.Foreground = true; doc.Template.Top = topSpace; //draw header label PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 9f, FontStyle.Italic)); PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Right); String label = "Demo about Header Repeating"; //set the header style SizeF size = font.MeasureString(label, format); float y = topSpace.Height - font.Height - 40; PdfPen pen = new PdfPen(Color.Black, 0.75f); topSpace.Graphics.SetTransparency(0.5f); topSpace.Graphics.DrawLine(pen, margin.Left - 30, y, pageSize.Width - margin.Right + 30, y); y = y - 1 - size.Height; topSpace.Graphics.DrawString(label, font, PdfBrushes.Black, pageSize.Width - margin.Right, y, format); PdfPageTemplateElement rightSpace = new PdfPageTemplateElement(margin.Right, pageSize.Height); doc.Template.Right = rightSpace; PdfPageTemplateElement bottomSpace = new PdfPageTemplateElement(pageSize.Width, margin.Bottom); bottomSpace.Foreground = true; doc.Template.Bottom = bottomSpace; }
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@wqylolg.cn
本文将为大家介绍DevExpress XAF如何将.NET Aspire集成到Blazor项目中,欢迎下载最新版组件体验!
JxBrowser是 TeamDev 开发的跨平台库,用于在 Java 应用程序中集成 Chromium 浏览器。它支持 HTML5、CSS3、JavaScript 等,具备硬件加速渲染、双向 Java 与 JavaScript 连接、丰富的事件监听等功能,能处理网页保存、打印等操作,助力 Java 应用高效展示和交互网页内容。
FastReport 不仅仅包含报表组件,它还提供更多功能!特别是,它有几个组件可以像其他 Delphi 组件一样在您的应用程序中使用,而且我们一直在向库中添加更多组件。在本文中,我们将介绍其中之一:TfrShellTreeView。
RFID 标签是一种现代化的产品识别方式,正在迅速取代条形码。RFID 标签的独特之处在于它使用无线电信号。这让您可以快速扫描大量物品,节省大量时间。RFID 标签也用于识别公司内部的员工。在本文中,我们将探讨 RFID 标签如何与FastReport VCL中新增的 TfrxDeviceCommand 对象配合使用。
专业的.NET Office套件,涵盖office文档创建、编辑、转换、管理和OCR内容识别等操作
Spire.Doc for .NETSpire.Doc for .NET 是一款专门对 Word 文档进行操作的 .NET 类库。
Spire.PDF for .NETSpire.PDF for .NET是独立的PDF控件,用于.NET程序中创建、编辑和操作PDF文档
Spire.PDF for WPFSpire.PDF for WPF 是一款让你的app能够读取、写入和操作PDF文档的完全独立的组件,不需要任何第三方组件库。
Spire.Email for .NET专业且独立使用的.NET 电子邮件库
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@wqylolg.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢