pdf - 恢复PDF图形状态后是否可以为路径绘制笔画?

标签 pdf

我在 PDF 中绘制线条,我想按 1:1 以外的比例缩放。

问题是我得到的笔画看起来像是用书法笔画的。

是否有可能在 PDF 中以某种方式调整路径大小,恢复图形状态,然后绘制先前路径的笔划。

这就是我在 PDF 中获得书法线条的方式:

5 w               // width of stroke
q                 // saves the current graphics state 
0 1 0 0.2 0 0 cm  // transformation matrix scaling with height reduced to 20%
0 10 m            // Start of line
10 10 l           // line to
20 100 l
30 100 l
40 10 l
S                 // draws stroke
Q                 // Restores graphics state

在 HTML5 canvas 中,可以在恢复图形状态后绘制描边,以便路径由等宽线绘制。

http://www.html5canvastutorials.com/advanced/html5-canvas-ovals/

在 PDF 中,将 S 放在 Q 之后是行不通的。

是否有某种方法可以在 PDF 中获得相同的结果,其中仅缩放线条路径,而不缩放笔划本身?

最佳答案

查看 PDF 规范第 113 页上的图 9 - 图形对象 ISO 32000-1:2008 .它说明一旦开始构建路径,唯一允许的运算符就是用于路径构建、路径裁剪和路径绘制的运算符。 Q 是一个特殊的图形状态运算符,只允许在路径绘制运算符之后,例如你的S

这也在图片正下方的示例中说明:

The path construction operators m and re signal the beginning of a path object. Inside the path object, additional path construction operators are permitted, as are the clipping path operators W and W*, but not general graphics state operators such as w or J. A path-painting operator, such as S or f, ends the path object and returns to the page description level.

因此响应“是否有某种方法可以在 PDF 中获得相同的结果,其中只有线路径被缩放,而不是笔划本身?”:不,您必须明确选择更小的笔划宽度来补偿不同的比例由变换矩阵引入。

Page 113 of ISO 32000-1:2008 showing Figure 9 - Graphics Objects

关于pdf - 恢复PDF图形状态后是否可以为路径绘制笔画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13622632/

相关文章:

c# - 在 C# 中将 pdf 文件转换为文本

mysql - 从 MySQL 数据生成 PDF 并使用 Postfix 发送它,而不使用 PHP?

C# 4.0 : Convert pdf to byte[] and vice versa

javascript - PDF.JS PDF 渲染不正确,出现镜像和颠倒

javascript - 是否可以在页面加载后立即强制下载文件(如 pdf)

java - 将 PDF 转换为 PNG (tess4j) - 本地工作正常,但在服务器 JBoss 中不工作

c# - 为什么 Adob​​e PDF 控件在外部调试时打不开? (错误 103)

使用 XObject 带有外部图像的 PDF

c# - (C#) 将 PDF 转换为逐页 JPEG(动态翻页引擎需要)

c# - 在PKCS7(CMS)中使用相同的响应XML签名对多个位置进行签名