pdf - The method getInstance(byte[]) is undefined for the type Document.. Android -


i generating pdf using droidtext liberary

i have following code

public void createpdf() {     document doc = new document();        try {             string path = environment.getexternalstoragedirectory().getabsolutepath() + "/droidtext";              file dir = new file(path);                 if(!dir.exists()){                      system.out.println("directory not exists");                      dir.mkdirs();              }else{                  system.out.println("directory exirsts");              }              system.out.println("path="+path);              log.d("pdfcreator", "pdf path: " + path);               file file = new file(dir, "sample.pdf");             fileoutputstream fout = new fileoutputstream(file);              pdfwriter.getinstance(doc, fout);              //open document             doc.open();               paragraph p1 = new paragraph("hi! generating first pdf using droidtext");             font parafont= new font(font.courier);             p1.setalignment(paragraph.align_center);             p1.setfont(parafont);               //add paragraph document                  doc.add(p1);               paragraph p2 = new paragraph("this example of simple paragraph");              font parafont2= new font(font.courier,14.0f,color.green);              p2.setalignment(paragraph.align_center);              p2.setfont(parafont2);               doc.add(p2); 

//

             //set footer              phrase footertext = new phrase("this example of footer");              headerfooter pdffooter = new headerfooter(footertext, false);              doc.setfooter(pdffooter);                  intent intent = new intent(intent.action_view);              intent.setdataandtype(uri.fromfile(file),"application/pdf");              intent.setflags(intent.flag_activity_no_history);              startactivity(intent);       } catch (documentexception de) {              log.e("pdfcreator", "documentexception:" + de);      } catch (ioexception e) {              log.e("pdfcreator", "ioexception:" + e);      }            {              doc.close();      }  }   

it works.. when add image using following lines, says "the method getinstance(byte[]) undefined type document"

   bytearrayoutputstream stream = new bytearrayoutputstream();              bitmap bitmap = bitmapfactory.decoderesource(getbasecontext().getresources(), r.drawable.ic_launcher);              bitmap.compress(bitmap.compressformat.jpeg, 100 , stream);              image myimg = image.getinstance(stream.tobytearray());              //myimg.setalignment(image.middle);                               add image document              doc.add(myimg); 

help me in adding images document

as per document.java, class doesn't have getinstance method. want image.getinstance per stackoverflow question,

e.g.

image myimg = image.getinstance(stream.tobytearray()); doc.add(myimg); 

which isn't duplicate question have answer answers statement of "help me in adding images document"


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -