Q:
I have an image that I want to use it as background.
// Image img = Image.create(doc.getSDFDoc(), (input_path + “peppers.jpg”));
//
// element = eb.createImage(img, new Matrix2D(img.getImageWidth()/2, -145, 20, img.getImageHeight()/2, 200, 150));
// writer.writePlacedElement(element);
//
// gstate = element.getGState(); // use the same image (just
// // change its matrix)
// gstate.setTransform(200, 0, 0, 300, 50, 450);
// writer.writePlacedElement(element);
//
// // use the same image again (just change its matrix).
// writer.writePlacedElement(eb.createImage(img, 300, 600, 200, -150));
I am not able to understand he input parameters to createImage or the setTransform
The Javadoc documentation shows as arg0, arg1 and provides no clue on how to use it.
- Can you please give me the argument description for creaqteImage and setTransform ?
- If I have an image and I need to stretch to the document width and length, how should I do that?
- If I want to replicate the same image how do I do that?
A:
We have a sample of how to use element builder on our website:
http://www.pdftron.com/pdfnet/samplecode/ElementBuilderTest.java
We also have documentation for our Java API:
http://www.pdftron.com/pdfnet/Javadoc/index.html
Our setTransform function requires a Matrix2D that represents an affine transformation.
In case you want to tile the background with an image, you should create a ‘tiling pattern’. Then you can use this patter to fill … let say a rectangle that cover the whole page. For a concrete example please see Pattern sample project: