c# - ITextSharp Defining a Pages Background Image: Whats the correct way? -


is possible set background image pdf page in itextsharp?

whats correct way define background image pdf page? there property of document set?

or creating image(my image has dimensions of a4 page)? if add background image normal image able place paragraphs on top of background image?

var document = new document(pagesize.a4, 50, 50, 25, 25); // create new pdfwrite object, writing output memorystream var output = new memorystream(); var writer = pdfwriter.getinstance(document, output); var logo = itextsharp.text.image.getinstance(server.mappath("~/images/test.jpg")); logo.setabsoluteposition(0,0); document.add(logo);  // following paragraph on top or below background image?  // aiming on top document.add( new paragraph("sjfkkjdsfk") );  document.close(); 

the logo fine - it's regular image content on page, not backgound img (like in html). put content on top of that, need use direct content:

pdfcontentbyte on = writer.directcontent; over.savestate(); over.begintext(); over.setfontandsize(basefont.createfont(), 9);         over.showtextaligned(element.align_left, "your text", x, y, 0); over.setlinewidth(0.3f);         over.endtext(); over.restorestate(); 

please note x , y cord bottom left corner. last parameter rotation.

another tip: doc.newpage(); if want start new page image background, the text cord on new page.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -