- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
问题是一个头文件,我必须在 abcpdf 生成的 pdf 文件的每一页上包含它。
头文件包含不止一个图像文件和几行文本,具体情况视情况而定。
问题是我不知道如何计算标题的大小。我需要有它的大小来分配矩形位置,以将每个页面上的其余 html 文件与标题一起放置。我正在使用 C#。
最佳答案
首先,您需要创建顶部有足够空间的文档,以便添加标题。以下设置适用于页眉约占页面 1/5 的普通 A4 文档。请记住 PDF 上的坐标是从右下角开始的,而不是从左上角开始的。
//Setting to create the document using ABCPdf 8
var theDoc = new Doc();
theDoc.MediaBox.String = "A4";
theDoc.HtmlOptions.PageCacheEnabled = false;
theDoc.HtmlOptions.ImageQuality = 101;
theDoc.Rect.Width = 719;
theDoc.Rect.Height = 590;
theDoc.Rect.Position(2, 70);
theDoc.HtmlOptions.Engine = EngineType.Gecko;
下面的代码在文档的每一页上放置了一个标题,带有标题图像,然后是图像下方的彩色框,其中包含一些自定义文本。
本例中的标题图像为 1710 x 381,以保持图像的分辨率尽可能高,以免打印时看起来模糊。
private static Doc AddHeader(Doc theDoc)
{
int theCount = theDoc.PageCount;
int i = 0;
//Image header
for (i = 1; i <= theCount; i++)
{
theDoc.Rect.Width = 590;
theDoc.Rect.Height = 140;
theDoc.Rect.Position(0, 706);
theDoc.PageNumber = i;
string imagefilePath = HttpContext.Current.Server.MapPath("/images/pdf/pdf-header.png");
Bitmap myBmp = (Bitmap)Bitmap.FromFile(imagefilePath);
theDoc.AddImage(myBmp);
}
//Blue header box
for (i = 2; i <= theCount; i++)
{
theDoc.Rect.String = "20 15 590 50";
theDoc.Rect.Position(13, 672);
System.Drawing.Color c = System.Drawing.ColorTranslator.FromHtml("#468DCB");
theDoc.Color.Color = c;
theDoc.PageNumber = i;
theDoc.FillRect();
}
//Blue header text
for (i = 2; i <= theCount; i++)
{
theDoc.Rect.String = "20 15 586 50";
theDoc.Rect.Position(25, 660);
System.Drawing.Color cText = System.Drawing.ColorTranslator.FromHtml("#ffffff");
theDoc.Color.Color = cText;
string theFont = "Century Gothic";
theDoc.Font = theDoc.AddFont(theFont);
theDoc.FontSize = 14;
theDoc.PageNumber = i;
theDoc.AddText("Your Text Here");
}
return theDoc;
}
关于c# - ABCPDF 标题大小和位置的计算。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13149160/
我正在尝试使用 ABCpdf 将 HTML 页面导出为 PDF。文本转换正常,但图表非常模糊。我尝试过增大字体大小,但效果甚微。解决办法是什么? 编辑:如果有帮助的话,我正在使用 asp.net 图表
我正在使用 ABCpdf,并且根本无法以编程方式获取文档的标题或作者。在 WebSupergoo 的网站上似乎找不到任何好的例子!应该是一个简单的问题。 Doc d = new Doc(); d.Re
我正在使用 ABCpdf 来提取一些 PDF 文件的文本内容,特别是通过调用 Doc.GetText("Text")。 (您循环调用它,每页一次。)这通常效果很好,但对于某些 PDF 文件,生成的文本
我已经使用 ABDpdf 呈现 pdf 并将其流式传输到浏览器,但我想知道是否可以将呈现的 pdf 附加到电子邮件中。有人做过吗? 我希望有一种方法不需要我将 pdf 保存到临时目录然后附加文件,然后
这可能更多是技术支持问题,但我想知道是否有其他开发人员遇到过这个问题: 我在我的 ASP.NET 代码中使用 Abcpdf 从 HTML 生成 PDF。它工作正常,但一个用户生成的 PDF 没有应用
我正在使用ABCPdf将HTML转换为PDF。我正在使用的方法: AddImageUrl() 这在Dev和UAT中工作正常,但在生产环境中,我不断收到以下消息: Unable to render HT
我使用 ABCpdf 9.1 x64 .Net 和 Coldfusion 创建基于 HTML 内容的 PDF。每个 PDF 文档都有不同的页眉和页脚,这些页眉和页脚是使用一些 Coldfusion 代
我正在使用 ABCPDF 库的 AddImageUrl 函数并让页面以 PDF 格式呈现。但是我遇到了一个问题,链接(标签)没有在 PDF 链接中呈现,而是作为没有链接功能的普通文本呈现。我已经检查了
我正在使用 ABCPDF.Net 版本 5 从 HTML 创建 PDF 文件。但是,这些链接似乎以深色突出显示,几乎无法阅读。如果我设置 pdfDoc.HtmlOptions.AddLinks = f
我有一个将 HTML 转换为 PDF 的 Windows 服务。我通过调用 嵌入自定义前端 var fontSwiftFont = pdfDoc.EmbedFont("swift-fontv2", L
当我尝试使用 ABCpdf 将每个页面保存为 GIF 时,只保存了第一页。 例如:我有一个包含 3 页的 PDF。我使用 ABCpdf 将每个页面呈现为流,并保存到磁盘。当我打开目标文件夹中的文件时,
在我的网站中,我使用 ABCpdf从 HTML 动态生成 pdf。我有两个条件: 用户已登录,显示第一页并将第一页绘制为 pdf 用户未登录显示在第二页并将第二页绘制为 pdf 我的代码是这样的:
问题是一个头文件,我必须在 abcpdf 生成的 pdf 文件的每一页上包含它。 头文件包含不止一个图像文件和几行文本,具体情况视情况而定。 问题是我不知道如何计算标题的大小。我需要有它的大小来分配矩
我正在试用 ABCPdf 8.1,在使用 AddImageUrl(...) 方法时出现以下错误: Access to the registry key 'HKEY_CURRENT_USER\Softw
我按照示例将带有页码的页脚添加到来自 abcpdf 文档站点的“页眉和页脚示例”页面。 问题是我的 pdf 文档有多个页面,方向和页面大小都不同。 大多数页面要么是纵向和 A4,要么是横向和 A3,但
我正在使用 ABCPDF 通过 EMF 文件将 PDF 文件打印到本地打印机。我非常密切地基于 ABC PDF 的示例“ABCPDFView”项目。我的应用程序在我的 Windows 7 和 Wind
我有一个系统,可以根据用户自己的图像创建 pdf 书籍。这些图像是高分辨率的,pdf 最终有大约 70 页,其中大部分都带有图片。 在服务器上的本地应用程序中生成 pdf 时,该过程使用大约 3Gb
我正在尝试将单选按钮添加到我通过 abcpdf 呈现的 pdf 页面。我正在查看 abcpdf 的文档,它指定我使用以下代码 Doc theDoc = new Doc(); InteractiveFo
是否可以使用 ABCPdf 将文档 JavaScript 添加到生成的 PDF 中? 最佳答案 如果您的意思是在文档加载后执行的 Javascript,请查看 this documentation p
我希望在将一段文本绘制到页面上并检查它的 y 位置之前判断一段文本是否适合页面底部。 有人知道 ABCPDF 是否可行吗? 最佳答案 据我所知,从我做 PDF 的时候开始(比如...... 6-7 年
我是一名优秀的程序员,十分优秀!