在iTextSharp的图像缩放, [英] scaling images in iTextSharp
问题描述
我有一些麻烦标定我正在插入的图像。
我必须做一些错误的,因为它并没有改变,无论我做什么。
这是代码中,我的那一刻,但它似乎并没有工作。
中的图像被插入精细,它只是不结垢,无论我尝试什么样的价值观。
任何明显的事情我做错了什么?任何普通的事情,人们做错了什么?
我在C#中的工作,但我相信语法是相同的(或多或少)在所有的语言。
图像imgSpine = Image.GetInstance(strSpine);
imgSpine.ScaleAbsolute(2,55);
SpineCell.Image = imgSpine;
SpineCell.Image.Border = Rectangle.NO_BORDER;
SpineCell.VerticalAlignment = Element.ALIGN_TOP;
SpineCell.HorizontalAlignment = Element.ALIGN_LEFT;
pTable.AddCell(SpineCell);
看着的来源, cell.Image
总是缩放以适应单元格。你会想包装在块图像
或一些类似元素
那将持有图片
。
的
call.Image
属性也总是写入在 PdfPTable.TEXTCANVAS
画布在PdfPTable,所以你不要有超过Z次序任何控制。
选项
- 包裹图像中的块而不是
- 使用单元格事件处理和绘制。像自己。
1号很可能的多的更容易。
I'm having some trouble scaling an image that i am inserting. I must be doing something wrong, because it does not change at all, no matter what i do. This is the code i have at the moment, but it does not seem to work. The image gets inserted fine, it just doesn't scale, no matter what values i try.
Any obvious things i am doing wrong? Any common things that people do wrong? I am working in C#, but i assume the syntax is the same (more or less) in all languages.
Image imgSpine = Image.GetInstance(strSpine);
imgSpine.ScaleAbsolute(2, 55);
SpineCell.Image = imgSpine;
SpineCell.Image.Border = Rectangle.NO_BORDER;
SpineCell.VerticalAlignment = Element.ALIGN_TOP;
SpineCell.HorizontalAlignment = Element.ALIGN_LEFT;
pTable.AddCell(SpineCell);
Looking at the source, cell.Image
is always scaled to fit the cell. You'll want to wrap your image in a Chunk
or some similar Element
that'll hold an Image
.
The call.Image
property is also always written to a the PdfPTable.TEXTCANVAS
canvas in the PdfPTable, so you don't have any control over Z order.
Options:
- Wrap the image in a Chunk instead.
- Use a Cell Event handler and draw the image yourself.
Number 1 is probably much easier.
这篇关于在iTextSharp的图像缩放,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!