var box = new Overlay();
PDDocument watermarkDoc = PDDocument.load("watermark.pdf"); //Assuming your empty document with watermark image in it. PDDocument realDoc = PDDocument.load("document-to-be-watermarked.pdf"); //Let's say this is your document that you want to watermark. For example sake, I am opening a new one, you would already have a reference to PDDocument if you are creating one Overlay overlay = new Overlay(); overlay.overlay(realDoc,watermarkDoc); watermarkDoc.save("document-now-watermarked.pdf");
import java.io.File; import java.util.HashMap; import org.apache.pdfbox.multipdf.Overlay; import org.apache.pdfbox.pdmodel.PDDocument; public class TestPDF { public static void main(String[] args) throws Exception{ PDDocument realDoc = PDDocument.load(new File("originaldocument.pdf")); //the above is the document you want to watermark //for all the pages, you can add overlay guide, indicating watermark the original pages with the watermark document. HashMap<Integer, String> overlayGuide = new HashMap<Integer, String>(); for(int i=0; i<realDoc.getNumberOfPages(); i++){ overlayGuide.put(i+1, "watermark.pdf"); //watermark.pdf is the document which is a one page PDF with your watermark image in it. //Notice here, you can skip pages from being watermarked. } Overlay overlay = new Overlay(); overlay.setInputPDF(realDoc); overlay.setOutputFile("final.pdf"); overlay.setOverlayPosition(Overlay.Position.BACKGROUND); overlay.overlay(overlayGuide); } }
public Overlay getPrototypeOverlay() { if (prototypeOverlay!=null) return prototypeOverlay; else return new Overlay(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); //no title getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //fullscreen overlay = new Overlay(this); setContentView(R.layout.main); addContentView(overlay, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); camera = getCameraInstance(); //camera.open(); preview = new Preview(this, camera); ((FrameLayout) findViewById(R.id.preview)).addView(preview); }
@Override @SuppressWarnings("unchecked") public <T> T convert(final Object src, final Class<T> dest) { if (!getInputType().isInstance(src)) throw new IllegalArgumentException( "Unexpected source type: " + src.getClass()); if (!getOutputType().isAssignableFrom(dest)) throw new IllegalArgumentException("Unexpected output class: " + dest); final ROITree rois = (ROITree) src; final Overlay o = new Overlay(); addROIs(rois, o); return (T) o; }
TourGuide mTourGuideHandler = TourGuide.init(this).with(TourGuide.Technique.Click) .setPointer(new Pointer()) .setToolTip(new ToolTip().setTitle("Welcome!").setDescription("Click on Get Started to begin...")) .setOverlay(new Overlay()) .playOn(button);
/** * @deprecated * replaced by ImagePlus.setOverlay(Roi, Color, int, Color) */ public void setDisplayList(Roi roi, Color color) { roi.setStrokeColor(color); Overlay list = new Overlay(); list.add(roi); setOverlay(list); }
/** * @deprecated * replaced by ImagePlus.setOverlay(Roi, Color, int, Color) */ public void setDisplayList(Roi roi, Color color) { roi.setStrokeColor(color); Overlay list = new Overlay(); list.add(roi); setOverlay(list); }
public void drawPaths(ImagePlus target, Map<Integer, GeodesicDiameter.Result> geodDiams) { Overlay overlay = new Overlay(); Calibration calib = target.getCalibration(); for (GeodesicDiameter.Result result : geodDiams.values()) { Roi roi = createPathRoi(result.path, calib); roi.setStrokeColor(Color.RED); overlay.add(roi); } target.setOverlay(overlay); }
public void drawDiameters(ImagePlus target, Map<Integer, PointPair2D> geodDiams) { Overlay overlay = new Overlay(); Calibration calib = target.getCalibration(); for (PointPair2D result : geodDiams.values()) { Roi roi = createDiametersRoi(result, calib); roi.setStrokeColor(Color.BLUE); overlay.add(roi); } target.setOverlay(overlay); }
/** Creates an Overlay from the specified ROI, and assigns it to this image. * @see #setOverlay(ij.gui.Overlay) */ public void setOverlay(Roi roi, Color strokeColor, int strokeWidth, Color fillColor) { roi.setStrokeColor(strokeColor); roi.setStrokeWidth(strokeWidth); roi.setFillColor(fillColor); setOverlay(new Overlay(roi)); }
/** Creates an Overlay from the specified ROI, and assigns it to this image. * @see #setOverlay(ij.gui.Overlay) */ public void setOverlay(Roi roi, Color strokeColor, int strokeWidth, Color fillColor) { roi.setStrokeColor(strokeColor); roi.setStrokeWidth(strokeWidth); roi.setFillColor(fillColor); setOverlay(new Overlay(roi)); }
void updateRoiList(Rectangle rect) { if (gel==null) return; if (overlay==null) { overlay = new Overlay(); overlay.drawLabels(true); overlay.setLabelColor(Color.white); overlay.drawBackgrounds(true); } overlay.add(new Roi(rect.x, rect.y, rect.width, rect.height, null)); gel.setOverlay(overlay); }
void updateRoiList(Rectangle rect) { if (gel==null) return; if (overlay==null) { overlay = new Overlay(); overlay.drawLabels(true); overlay.setLabelColor(Color.white); overlay.drawBackgrounds(true); } overlay.add(new Roi(rect.x, rect.y, rect.width, rect.height, null)); gel.setOverlay(overlay); }
/** Returns a new Overlay that has the same properties as this one. */ public Overlay create() { Overlay overlay2 = new Overlay(); overlay2.drawLabels(label); overlay2.drawNames(drawNames); overlay2.drawBackgrounds(drawBackgrounds); overlay2.setLabelColor(labelColor); overlay2.setLabelFont(labelFont, scalableLabels); overlay2.setIsCalibrationBar(isCalibrationBar); overlay2.selectable(selectable); return overlay2; }
void addRoi(ImagePlus imp, Roi roi){ Overlay overlay = imp.getOverlay(); if (overlay==null || overlay.size()==0) { if (offscreenOverlay==null) offscreenOverlay = new Overlay(); overlay = offscreenOverlay; } if (defaultColor!=null) roi.setStrokeColor(defaultColor); roi.setStrokeWidth(getProcessor().getLineWidth()); overlay.add(roi); }
public void setPrototypeOverlay(Overlay overlay) { prototypeOverlay = new Overlay(); prototypeOverlay.drawLabels(overlay.getDrawLabels()); prototypeOverlay.drawNames(overlay.getDrawNames()); prototypeOverlay.drawBackgrounds(overlay.getDrawBackgrounds()); prototypeOverlay.setLabelColor(overlay.getLabelColor()); prototypeOverlay.setLabelFont(overlay.getLabelFont(), overlay.scalableLabels()); }
public void setPrototypeOverlay(Overlay overlay) { prototypeOverlay = new Overlay(); prototypeOverlay.drawLabels(overlay.getDrawLabels()); prototypeOverlay.drawNames(overlay.getDrawNames()); prototypeOverlay.drawBackgrounds(overlay.getDrawBackgrounds()); prototypeOverlay.setLabelColor(overlay.getLabelColor()); prototypeOverlay.setLabelFont(overlay.getLabelFont(), overlay.scalableLabels()); }