title: PDF Viewer via Pdf-Reader---Writer in Android
body: <p>I have to implement PDF viewer library in project I am following <a href="https://github.com/bhavyahmehta/Pdf-Reader---Writer/blob/master/Pdf_%20Reader_Writer/README.md" rel="nofollow">https://github.com/bhavyahmehta/Pdf-Reader---Writer/blob/master/Pdf_%20Reader_Writer/README.md</a>
  In this example they are creating PDF and loading in viewer. 
  Actually I understood how library works Here is the below snippet of code for creating and loading PDF from library:</p>
  
  <pre><code>            @Override
      protected Void doInBackground(Void... params)
      {
      String pdfcontent = generateHelloWorldPDF(); //generating pdf content
      outputToFile("PdfSample.pdf",pdfcontent,"ISO-8859-1"); //passing pdf name and content
          return null;
      }
  
            private String generateHelloWorldPDF() 
            { //function returns pdf content with pages
          PDFWriter mPDFWriter = new PDFWriter(PaperSize.FOLIO_WIDTH, PaperSize.FOLIO_HEIGHT);
  
  
      try {
          // all image formates are supported
          Bitmap i1 = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);   
          mPDFWriter.addImage(40, 60, i1, Transformation.DEGREES_315_ROTATION);
          mPDFWriter.addImage(72, 72, i1);
          mPDFWriter.addImage(200, 400, 135, 75, i1);
          mPDFWriter.addImage(150, 300, 130, 70, i1);
          mPDFWriter.addImageKeepRatio(100, 200, 50, 25, i1);
          mPDFWriter.addImageKeepRatio(50, 100, 30, 25, i1, Transformation.DEGREES_270_ROTATION);
          mPDFWriter.addImageKeepRatio(25, 50, 30, 25, i1);
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      mPDFWriter.setFont(StandardFonts.SUBTYPE, StandardFonts.TIMES_ROMAN);
      mPDFWriter.addRawContent("row content \n");
      mPDFWriter.addText(70, 50, 12, "hello world");
      mPDFWriter.setFont(StandardFonts.SUBTYPE, StandardFonts.COURIER, StandardFonts.WIN_ANSI_ENCODING);
      mPDFWriter.addRawContent("row content rg\n");
      mPDFWriter.addText(30, 90, 10, "ï¿½ CRL", Transformation.DEGREES_270_ROTATION);
  
      mPDFWriter.newPage();
      mPDFWriter.addRawContent("[] 0 d\n");
      mPDFWriter.addRawContent("1 w\n");
      mPDFWriter.addRawContent("0 0 1 RG\n");
      mPDFWriter.addRawContent("0 1 0 rg\n");
      mPDFWriter.addRectangle(40, 50, 280, 50);
      mPDFWriter.addText(85, 75, 18, "Android Docs");
  
      mPDFWriter.newPage();
      mPDFWriter.setFont(StandardFonts.SUBTYPE, StandardFonts.COURIER_BOLD);
     // mPDFWriter.addText(150, 150, 14, "http://coderesearchlabs.com");
      mPDFWriter.addLine(150, 140, 300, 140);
  
      String s = mPDFWriter.asString();
      return s;
  }
  
  
           private void outputToFile(String fileName, String pdfContent, String encoding)        { //function which pushes the file to below path
      //System.out.println("content" +fileName);
     if(isSDPresent)
     {
  
         try {
                  File dir = new File(Environment.getExternalStorageDirectory() + "/pdf_Writer_Reader/");
                  if (!dir.exists())
                  {
                      dir.mkdirs();
                  }
  
                  newFile = new File(dir,fileName);
                  if(!newFile.exists())
                  {
                      newFile.createNewFile();
                  }
  
                 try
                 {
                      FileOutputStream pdfFile = new FileOutputStream(newFile);
                      pdfFile.write(pdfContent.getBytes(encoding));               
                      pdfFile.close();
                 }
                 catch(FileNotFoundException e) {
                  Log.e("Ex==",""+e.toString());
                 }
         } 
         catch(IOException e)
         {
          Log.e("Ex==",""+e.toString());
         }
     }
  </code></pre>
  
  <p>can anybody suggest on how to load PDF from sdcard any help will be thankful. </p>