Hello, I am trying to set text in absolute positions using iText (code
below). Everything works fine in my code except that part. I always get an
error:

Class coldfusion.runtime.java.JavaProxy can not access a member of class
com.lowagie.text.pdf.PdfWriter with modifiers "protected"

All examples to set text at absolute position require access to
writer.getDirectContent().  I am in desperate need of help solving this
issue. Anyone have any ideas.

<cfscript>
fpath = "c:\\windows\\fonts\\";

paths = arrayNew(1);
paths[1] = expandPath("jar\iText.jar");
loader = createObject("component", "javaloader.JavaLoader").init(paths);

// create a Document object
rectangle = loader.create("com.lowagie.text.Rectangle");
pageSize = rectangle.init(599, 400);
element = loader.create("com.lowagie.text.Element");
content = loader.create("com.lowagie.text.pdf.PdfContentByte");
document = loader.create("com.lowagie.text.Document").init(pageSize, 0, 0,
0, 0);


// create a Image object
Image = loader.create("com.lowagie.text.Image");

// create a Writer object
fileIO = loader.create("java.io.FileOutputStream");
fileIO.init(#expandpath("pdf\pc1.pdf")#);
writer = loader.create("com.lowagie.text.pdf.PdfWriter");
writer.getInstance(document, fileIO);

// create a Font object
BaseFont = loader.create("com.lowagie.text.pdf.BaseFont");
Font = loader.create("com.lowagie.text.Font"); 
arialBF = BaseFont.createFont("#fpath#arial.ttf", BaseFont.CP1252,
BaseFont.NOT_EMBEDDED);
arialBF = Font.init(arialBF, 12, 5);

document.open();

//add an image
jpg =
Image.getInstance("#expandpath("images/1001_ExtHrs_6x41_Page_1.jpg")#");
jpg.setAbsolutePosition(0, 0);
jpg.scaleToFit(600, 400);
jpg.setDpi(300,300);
jpg.setAlignment(Image.UNDERLYING);
document.add(jpg);

//create page 2
document.newPage();


//add an image
jpg =
Image.getInstance("#expandpath("images/1001_ExtHrs_6x41_Page_2.jpg")#");
jpg.setAbsolutePosition(0, 0);
jpg.scaleToFit(600, 400);
jpg.setDpi(300,300);
jpg.setAlignment(Image.UNDERLYING);
document.add(jpg);

//write line of text
Line1 = content.init(writer.getDirectContent()); 
Line1.beginText(); 
Line1.setFontAndSize(arialBF, 26); 
text = "Show this text on the pdf."; 
Line1.showTextAligned(1, text, 250, 700, 0); 
Line1.endText();


document.close();
</cfscript>
-- 
View this message in context: 
http://www.nabble.com/iText-Error-tf2961693.html#a8286186
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to