1
我試圖放大PDF粘滯便箋的圖標。下面是表明我對PDF的第一頁上的蓋章上下文粘圖標的圖像:如何更改通過iTextSharp放置的PDF便籤的圖標大小?
我的印象圖標被可能被操縱的矩形引導。這裏是我的代碼沒有得到有效尚未:
using (PdfStamper stamp = new PdfStamper(reader, fs))
{
PdfWriter attachment = stamp.Writer;
foreach (string file in files_to_attach)
{
PdfFileSpecification pdfAttch = PdfFileSpecification.FileEmbedded(attachment, file, file, null);
stamp.AddFileAttachment(file, pdfAttch);
}
//Create Note for first page
Rectangle rect = new Rectangle(850, 850, 650, 650);
PdfAnnotation annotation = PdfAnnotation.CreateText(stamp.Writer, rect, "TITLE OF NOTE", "Body text of the note", false, "Comment");
//Enlarge the Sticky Note icon
PdfDictionary page = reader.GetPageN(1);
PdfArray annots = page.GetAsArray(PdfName.ANNOTS);
PdfDictionary sticky = annots.GetAsDict(0);
PdfArray stickyRect = sticky.GetAsArray(PdfName.RECT);
PdfRectangle stickyRectangle = new PdfRectangle(
stickyRect.GetAsNumber(0).FloatValue - 50, stickyRect.GetAsNumber(1).FloatValue - 20,
stickyRect.GetAsNumber(2).FloatValue, stickyRect.GetAsNumber(3).FloatValue - 30);
sticky.Put(PdfName.RECT, stickyRectangle);
//Apply the Note to the first page
stamp.AddAnnotation(annotation, 1);
stamp.Close();
}
我想我可以改變浮點值,並且將改變圖標的形狀,但到目前爲止還沒有實現這一切。謝謝你的任何建議。
因此,爲了讓它「以同樣的方式向最終用戶使用」,它仍然需要表示爲註釋,對嗎?如: PdfAnnotation annotation = PdfAnnotation.CreateText(stamp。作家,rect,「標題筆記」,「筆記正文」,假,「評論」); 但不是「評論」,我會通過一個圖像。 「評論」是一個字符串,什麼語法允許圖像成爲一個字符串? – DBlair
請參閱Bruno的AddStamp示例。這是Java,但你會明白。 http://developers.itextpdf.com/examples/actions-and-annotations/clone-creating-and-adding-annotations#2260-addstamp.java – joelgeraci