pdf - How to add watermark to a landscape file using pdfbox -


i'm using pdfbox 1.8.11 , fop add water mark pdf:s. works nicely input pdf files. problem when file in landscape, watermarking 90 degree right rotated. had similar problem visible signature, fixed. solution in sign landscape file . idea how make water mark rotation works? in advance!

the original picture watermark is: up arrow

after fop watermark image rotated: image rotated

apologize answer late. idea 'water mark' here add add transforms original pdf using fop apache fop. can fine java code example , fo template example apache fop website.

in case illustrate example here too: 1. java code of how use fop

import org.apache.fop.apps.*; import org.xml.sax.*; import java.io.*; import javax.xml.transform.*; import javax.xml.transform.sax.*; import javax.xml.transform.stream.*;  class rendtest {      private static fopfactory fopfactory = fopfactory.newinstance(new file(".").touri());     private static transformerfactory tfactory = transformerfactory.newinstance();      public static void main(string args[]) {         outputstream out;         try {             //load stylesheet             templates templates = tfactory.newtemplates(                 new streamsource(new file(args[1])));              //first run (to /dev/null)             out = new org.apache.commons.io.output.nulloutputstream();             fouseragent fouseragent = fopfactory.newfouseragent();             fop fop = fopfactory.newfop(mimeconstants.mime_pdf, fouseragent, out);             transformer transformer = templates.newtransformer();             transformer.setparameter("page-count", "#");             transformer.transform(new streamsource(new file(args[0])),                 new saxresult(fop.getdefaulthandler()));              //get total page count             string pagecount = integer.tostring(driver.getresults().getpagecount());              //second run (the real thing)             out = new java.io.fileoutputstream(args[2]);             out = new java.io.bufferedoutputstream(out);             try {               fouseragent = fopfactory.newfouseragent();               fop = fopfactory.newfop(mimeconstants.mime_pdf, fouseragent, out);               transformer = templates.newtransformer();               transformer.setparameter("page-count", pagecount);               transformer.transform(new streamsource(new file(args[0])),                   new saxresult(fop.getdefaulthandler()));             } {                 out.close();             }         } catch (exception e) {             e.printstacktrace();         }     } } 
  1. for problem had rendering landscape pdf:s, in fop template need add 1 more attribute tell file in landscape layout. attribute set reference-orientation="90". other definitions in fop template applied properly.

Comments