如何在pdf中控制有效性图标的大小
签名后,我一直在尝试至少2天来控制pdf文件的有效性图标的大小。
该图标通常由pdf阅读器设置。
我尝试过不同的方法来解决这个问题:
- 重新标记签名注释矩形 – 它重塑了其中的所有内容
- 重新标记了签名注释外观BBox – 它还重塑了文本和图标内容。
- 我也尝试重塑n2和n0层,并创建了一个新的n5,期望能够控制它的大小而没有成功
最后,我只想单独调整有效性图标的大小。
任何建议都应该深表感谢。
dsblank = Annotation::AppearanceStream.new.setFilter(:FlateDecode) dsblank.Type=Name.new("XObject") dsblank.Resources = Resources.new dsblank.BBox = [ 0, 0, width, height ] dsblank.draw_stream('% DSBlank') n2 = Annotation::AppearanceStream.new.setFilter(:FlateDecode) n2.Resources = Resources.new n2.BBox = [ 0, 0, width, height ] n2.draw_stream('% DSBlank') n5 = Annotation::AppearanceStream.new.setFilter(:FlateDecode) n5.Resources = Resources.new n5.BBox = [ 0, 0, width, height ] n5.write(caption,x: padding_x, y: padding_y, size: text_size, leading: text_size ) sigannot = Annotation::Widget::Signature.new sigannot.Rect = Rectangle[ llx: x, lly: y, urx: x+width, ury: y+height ] sigannot.F = Annotation::Flags::PRINT #sets the print mode on # # Creates the stream for the signature appearance # streamN = Annotation::AppearanceStream.new.setFilter(:FlateDecode) streamN.BBox = [ 0, 0,width, height] streamN.Resources = Resources.new streamN.Resources.add_xobject(Name.new("n0"), dsblank) streamN.Resources.add_xobject(Name.new("n1"), dsblank) streamN.Resources.add_xobject(Name.new("n2"), n2) streamN.Resources.add_xobject(Name.new("n3"), dsblank) streamN.Resources.add_xobject(Name.new("n5"), n5) streamN.draw_stream('q 1 0 0 1 0 0 cm /n0 Do Q') streamN.draw_stream('q 1 0 0 1 0 0 cm /n1 Do Q') streamN.draw_stream('q 1 0 0 1 0 0 cm /n2 Do Q') streamN.draw_stream('q 1 0 0 1 0 0 cm /n3 Do Q') streamN.draw_stream('q 1 0 0 1 0 0 cm /n5 Do Q') sigannot.set_normal_appearance(streamN) page.add_annot(sigannot)
这不是一个答案,显示如何解决它, 但更多的评论认为,尝试它是一个坏主意。 但是,对于评论领域来说,它太大了。
您正在尝试制作PDF以支持Adobe已经开始逐步淘汰Adobe Reader 9的Adobe Readerfunction!
( Adobe Acrobat 9数字签名,更改和改进的第10页)
因此,即使您使用当前的Adobe Reader实现了目前的目标,也很容易发生在即将推出的新Adobe Reader版本中,此function的支持将完全停止。
此外,您不会在当前的PDF规范ISO 32000-1中找到任何提及此function(更改签名外观),更不用说即将推出的ISO 32000-2。
此外,在Acrobat 6.0中已停止维护除n0和n2之外的图层支持:
( Adobe®Acrobat®SDK数字签名外观,版本1。0,2006年10月第8页)
经过一些迭代后,我设法得到streamN和n2的比例因子3,以及padding_y。 我还添加了增加text_size。
有了这个,我设法减少了图标的大小,仍然有清晰的文字。
n2 = Annotation::AppearanceStream.new n2.Resources = Resources.new n2.BBox = [ 0, 0, width*3, height*3 ] n2.write(caption,x: padding_x, y: padding_y*3, size: text_size, leading: text_size ) sigannot = Annotation::Widget::Signature.new sigannot.Rect = Rectangle[ llx: x, lly: y, urx: x+width, ury: y+height ] sigannot.F = Annotation::Flags::PRINT #sets the print mode on # # Creates the stream for the signature appearance # streamN = Annotation::AppearanceStream.new.setFilter(:FlateDecode) streamN.BBox = [ 0, 0, width*3, height*3 ]