如何控制PDF中的有效性图标的大小 [英] How to control size of validity icon in a pdf
问题描述
我已经尝试了至少2天,以便在签名后控制pdf文件有效性图标的大小.
I've been trying for at least 2 days now to control the size of the validity icon of a pdf file, when signed.
图标通常由pdf阅读器设置.
The icon is set by the pdf reader usually.
我已经尝试了不同的方法来解决这个问题:
I've tried different approaches to the problem :
- 重新设计了签名注释矩形-重塑了矩形 中的所有内容
- 重新设计了签名注释外观BBox- 重塑了文字和图标的内容.
- 我还尝试过重塑n2和n0层,并创建了一个新层 n5,希望能够成功控制大小
- Redimensioned the Signature Annotation Rectangle - which reshaped all the contents within
- Redimensioned the Signature Annotation Appearance BBox - which also reshaped the text and icon contents.
- I've also tried to reshape n2 and n0 layers, and created a new one n5, expecting to be able to control it's size without success
最后,我只想单独调整有效性图标的大小.
In the end, I would just want to individually resize the validity icon.
任何建议都将深表感谢.
Any suggestions shall be deeply appreciated.
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)
推荐答案
经过几次迭代,我设法使streamN和n2以及padding_y的比例因子为3.我还增加了text_size.
After some iterations I managed to get a scale factor of 3 for streamN and n2, as well as padding_y. I also add to increase the text_size.
通过这种方式,我设法减小了图标的大小,并且仍然有清晰的文字.
With that I managed to reduce the size of the icon, and still have legible text.
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 ]
这篇关于如何控制PDF中的有效性图标的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!