By Date: <-- -->
By Thread: <-- -->

create external link in existing pdf



I am wanting to add an external link to an existing page from a pdf.  If I
understand it correctly, I use the PdfStamper object.  In my complete code,
I will calculate the X,Y coordinates & the width,height.

Here is my code so far (it does not work)...

import java.io.FileOutputStream;
import java.net.URL;

import com.lowagie.text.Anchor;
import com.lowagie.text.Annotation;
import com.lowagie.text.Document;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfAction;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;

public class Main {

	public static void main(String[] args) {
		
		try {
			PdfReader reader = new PdfReader("c:\\data\\APlainTest.pdf");
			int n = reader.getNumberOfPages();
			
			PdfStamper stamp = new PdfStamper(reader,new
FileOutputStream("c:\\data\\itext.pdf"));
			
			int i = 0;
			PdfContentByte under;
			PdfContentByte over;
			
			while (i < n) {
				i++;
				
//I don't know how to add this to the existing page, so I tried a PdfAction,
that still did not work
Annotation a1 = new Annotation(100f,100f,100f,100f,new
URL("http://www.pubpress.com";));
				
				
				under = stamp.getUnderContent(i);
				PdfAction action = new PdfAction(new URL("http://www.mytestsite.com";));
				under.setAction(action,100f,100f,100f,100f);
				
				over = stamp.getOverContent(i);
				over.setAction(action,100f,100f,100f,100f);
				
			}
			
			stamp.close();
			
		}
		catch (Exception e) {
			
		}
	}
	
}

-- 
View this message in context: http://www.nabble.com/create-external-link-in-existing-pdf-tf2585177.html#a7207485
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions (at) lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions