#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    Unable to view a PDF content generated through itext


    Hi All,

    We are generating a PDF through java program(using itext) which will run in VMS System for few PDF's we are unable to see the content even though it shows some size on disk.

    We are sending the PDF's thorugh mail using MAIL API.Then when we download the attcahment and see there are pages but unable to see the content please help me on this.

    Java mail code looks like this

    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setText(messageContent);

    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);
    MimeBodyPart mbp2=null;
    if(StringUtils.isNotBlank(fileName)){
    mbp2 = new MimeBodyPart();
    try {
    mbp2.attachFile(new File(fileName));
    } catch (IOException e) {
    e.printStackTrace();
    }
    mbp2.setHeader("Content-Type", "text/plain;charset=\"us-ascii\";name=\"" + fileName + "\"");
    mp.addBodyPart(mbp2);
    }

    msg.setContent(mp);
    Transport.send(msg);

    Thanks,
    Satyanath
  2. #2
  3. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    I think you need a different mime type

    Code:
    mbp2.setHeader("Content-Type", "text/plain;charset=\"us-ascii\";name=\"" + fileName + "\"");
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0
    Can you please suggest me which is suitable?
  6. #4
  7. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    Originally Posted by satyanath5
    Can you please suggest me which is suitable?
    I would use application/pdf
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    3
    Rep Power
    0
    Small doubt but some of the customers are able to see there BILLS in PDF which is sent by the same code in Which environments it's fails?

IMN logo majestic logo threadwatch logo seochat tools logo