Thursday, 22 August 2013

getting PDFParseException: Data format exception:incorrect data check

getting PDFParseException: Data format exception:incorrect data check

I am new to Itext. I am writing an application to create a image by
parsing a pdf file. my code is:
PdfReader reader = new PdfReader(TTFpath + "/image.pdf");
File directory = new File(uploadedpath);
File previewFile = File.createTempFile("sarath"+ imageType, ".pdf",
directory);
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream(previewFile));
PdfContentByte pdfcb = stamper.getOverContent(1);
BaseFont basef = BaseFont.createFont(TTFpath + "/" + fileName,
BaseFont.WINANSI, BaseFont.EMBEDDED);
pdfcb.beginText();
pdfcb.setFontAndSize(basef, fontSize);
float floatWidth = pdfcb.getEffectiveStringWidth(userName, true);
RandomAccessFile raf= new RandomAccessFile(file, "r");
FileChannel channel = raf.getChannel();
ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0,
channel.size());
PDFFile pdffile = new PDFFile(buf);
PDFPage page = pdffile.getPage(0);
Exactly after last line of code i am getting exception like "GetPage inner
loop: com.sun.pdfview.PDFParseException: Data format exception:incorrect
data check". What may be cause?

No comments:

Post a Comment