1. vishal.er07's Avatar

    Hello Guys,
    I am making an application in which I need to convert selected .doc file into .pdf file..I am not getting why I

    am geeting the error which I have mentioned below.I am using iText 5.1.1 to do file operations related to .doc &

    .pdf..Any single help/hint will be appreciated..Thanks in advance..
    This is my code of onClick() event for "Convert" button::

    String[] paragraphs = null;

    //Color clr=new Color();
    try {


    POIFSFileSystem fs = null;
    try {


    InputStream is = new FileInputStream(
    "/sdcard/Spring.doc");

    WordExtractor we = new WordExtractor(is);

    paragraphs = we.getParagraphText();

    System.out.println("Word Document has " + paragraphs.length
    + " paragraphs");
    for (int i = 0; i < paragraphs.length; i++) {
    paragraphs[i] = paragraphs[i].replaceAll("\\cM?\r?\n",
    "");
    System.out.println("Length:" + paragraphs[i].length());
    }
    } catch (Exception e) {
    e.printStackTrace();
    }



    Document document = new Document(PageSize.A4, 36, 72, 108, 180);
    PdfWriter.getInstance(document, new FileOutputStream(
    "/sdcard/pdfFile.pdf"));
    document.open();

    System.out.println("Text is inserted into pdf file");
    document.close();
    } catch (Exception e) {
    }

    ==========================================================
    This is my imports which I have used ::

    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;

    import org.apache.poi.hwpf.extractor.WordExtractor;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;


    import android.graphics.*;
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;

    import com.action.R;
    import com.lowagie.text.Document;
    import com.lowagie.text.PageSize;
    import com.lowagie.text.pdf.PdfWriter;
    ==========================================================

    And the error I am geeting is ::


    E/dalvikvm(3192): Could not find class 'com.lowagie.text.pdf.ExtendedColor', referenced from method

    com.lowagie.text.pdf.PdfWriter.checkPDFXConformance
    E/dalvikvm(3192): Could not find class 'java.awt.Color', referenced from method

    com.lowagie.text.pdf.PdfDocument.writeLineToContent
    E/dalvikvm(3192): Could not find class 'com.lowagie.text.pdf.PdfGraphics2D', referenced from method

    com.lowagie.text.pdf.PdfContentByte.createGraphics
    E/dalvikvm(3192): Could not find class 'com.lowagie.text.pdf.PdfPrinterGraphics2D', referenced from method

    com.lowagie.text.pdf.PdfContentByte.createPrinterGraphics
    samyakahd likes this.
    03-13-2012 08:55 AM
  2. samyakahd's Avatar
    Hello,

    I am also getting same error while executing my application.


    Thanks,
    03-14-2012 03:48 AM
  3. vishal.er07's Avatar
    Guys this problem has been solved..But now I am getting another problem..I am able to convert only text..I need the code sample which can read image from .doc file & write that into pdf file..

    Anyone who has any idea is most welcomed...

    Thanks in advance
    03-16-2012 04:45 AM
LINK TO POST COPIED TO CLIPBOARD