Q: I try to use PDFSDK.NET to add an image as overlay on a PDF file. I
use the sample code from PDFLayerTestCS and try to modify for our
testing. Here is my sample code,
static Obj CreateGroup1(PDFDoc doc, Obj layer) {
...
Element element = builder.CreateImage(img, 200, 200, 10, 10);
..
}
CreateImage(img, x, y, hscale, yscale) will place the image on (x,y)
position, however, for the scale,
What values should I place for these? If I want to keep the size of
the image, should I put 1 for the scale? How about scale to Half?
By the way, the coordinates for x,y, are they measured from the lower-
left corner?
-----------------
A: For a more basic image stamping approach you may want to take a
look at AddImage sample project instead of PDFLayerTestCS . PDFLayer
sample is only useful if you have a strict requirement to create PDFs
with OCGs (Optional Content Groups).
You could use img.GetImageWidth()/Height() multiplied by some scaling
factor:
Element element = builder.CreateImage(img, 10, 10, img.GetImageWidth()
* 0.5, img.GetImageHeight() * 0.5);
Alternatively you could use the ratio between img.GetImageWidth()/
Height() as the aspect ratio and use it a multiplier for a fixed
dimensions of the image.
coordinates for x,y, are they measured from the lower-left corner?
Correct.