Texte rendering mode avec PDFBox
Salut à tous,
Je suis entrain d'effectuer un "text rendering mode" avec PDFBox. J'ai écrit ce code mais je ne sais pas comment faut il appeler la fonction "process"??.
Voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| public class Test1 extends OperatorProcessor{
private static final String src="...";
private static PDFStreamEngine pp;
private static PDPageContentStream content;
private static PDType1Font font;
public static void CreatePdf(String src) throws IOException, COSVisitorException{
PDRectangle rec= new PDRectangle(400,400);
PDDocument document= null;
document = new PDDocument();
PDPage page = new PDPage(rec);
document.addPage(page);
PDDocumentInformation info=document.getDocumentInformation();
info.setAuthor("PdfBox");
info.setCreator("Pdf");
info.setSubject("Stéganographie");
info.setTitle("Stéganographie dans les documents PDF");
info.setKeywords("Stéganographie, pdf");
content= new PDPageContentStream(document, page);
pp=new PDFStreamEngine();
font= PDType1Font.HELVETICA;
String texte="hello";
content.beginText();
content.setFont(font, 12);
content.moveTextPositionByAmount(15, 385);
content.drawString(texte);
content.endText();
content.close();
document.save("doc.pdf");
document.close();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException, COSVisitorException {
// TODO code application logic here
Test1 tes= new Test1();
tes.CreatePdf(src);
}
@Override
public void process(PDFOperator pdfo, List<COSBase> list) throws IOException {
COSNumber mode = (COSNumber)list.get(0);
pp.getGraphicsState().getTextState().setRenderingMode(mode.intValue());
}
} |
Merci d'avance.