Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8497751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:12:55+00:00 2026-06-11T00:12:55+00:00

iTextPDF in android sets a border in the images in the PDF which I

  • 0

iTextPDF in android sets a border in the images in the PDF which I don’t want. How to solve this issue.
NB:- I searched a lot for a solution,I couldn’t find any.

com.itextpdf.text.Document pdfDocument  =   new com.itextpdf.text.Document();
    pdfDocument.setPageSize(PageSize.A4);
    pdfDocument.setMargins(72f,72f,72f,72f);                                                                        

    File extStore           =   Environment.getExternalStorageDirectory();

    try {
        PdfWriter.getInstance(pdfDocument,new FileOutputStream(extStore.getAbsolutePath()+"/MyNewPDF.pdf"));
    } catch (FileNotFoundException e1) {
        e1.printStackTrace();
    } catch (DocumentException e1) {
        e1.printStackTrace();
    }

    pdfDocument.open();

    BaseColor colorBlack    =   new BaseColor(0, 0, 0);                                                             

    /*Setting the Image Header*/
    Drawable myImage                =       getResources().getDrawable(R.drawable.pdf_logo);
    Bitmap bitmap                   =       ((BitmapDrawable)myImage).getBitmap();
    ByteArrayOutputStream stream    =       new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
    byte[] bitmapdata = stream.toByteArray();

    Image imageHeader = null;

    try {
        imageHeader = Image.getInstance(bitmapdata);
    } catch (BadElementException e1) {
        e1.printStackTrace();
    } catch (MalformedURLException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    imageHeader.setAlignment(Element.ALIGN_RIGHT);                                                                  
    Font font = new Font(Font.FontFamily.UNDEFINED,15,Font.ITALIC);
    try {
        pdfDocument.add(imageHeader);
        pdfDocument.add(Chunk.NEWLINE);
        /*Setting the heading line*/
        pdfDocument.add(new Paragraph("Document Name: Qwert Document ID: Dgj",font));
    } catch (DocumentException e1) {
        e1.printStackTrace();
    }  


    /*Black Line*/
    Chunk linebreak         =   new Chunk(new LineSeparator(1f, 100f, colorBlack, Element.ALIGN_CENTER, -1));
    try {
        pdfDocument.add(linebreak);
        pdfDocument.add( Chunk.NEWLINE );
        pdfDocument.add( Chunk.NEWLINE );
        pdfDocument.add( Chunk.NEWLINE );
        pdfDocument.add( Chunk.NEWLINE );
    } catch (DocumentException e) {
        e.printStackTrace();
    }

    /*Main Image*/
    Bitmap bitMap                   =   mBitmapArray.get(mPager.getCurrentItem()).mBitmap;
    ByteArrayOutputStream streamNew =   new ByteArrayOutputStream();
    bitMap.compress(Bitmap.CompressFormat.PNG, 100, streamNew);
    byte[] byteArray = streamNew.toByteArray();

    Image imageMain = null;
    try {
        imageMain = Image.getInstance(byteArray);
    } catch (BadElementException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    imageMain.setAlignment(Element.ALIGN_CENTER);
    try {
        pdfDocument.add(imageMain);
        pdfDocument.add( Chunk.NEWLINE );
        pdfDocument.add( Chunk.NEWLINE );
        pdfDocument.add( Chunk.NEWLINE );
    } catch (DocumentException e) {
    }


    Chunk linebreak2        =   new Chunk(new LineSeparator(2f, 100f, colorBlack, Element.ALIGN_CENTER, -1));
    try {
        /*Black Line*/
        pdfDocument.add(linebreak2);
        /*Last Line*/
        pdfDocument.add(new Paragraph("Sent by Traveler ID"));
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    pdfDocument.close();

Thanking you in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:12:57+00:00Added an answer on June 11, 2026 at 12:12 am

    I solved the issue by using another library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this code: require 'java' require 'iText-5.0.6.jar' module Pdf include_package com.itextpdf.text.pdf include_package java.io
Hey, There's a lot of posts on here about read barcodes but I want
Can we create PDF file in android? I have Tried all Google Search. Also
I want to extract the text from a pdf-file on the internet to a
I work on this demo project http://itextpdf.com/download.php when i try to build my api
I'm building a table for a pdf using iTextPdf. Each page will have between
I want to show a pdf file within my application. I have kept pdf
i rewrote the Example of iText (Java) http://itextpdf.com/examples/iia.php?id=297 in iTextSharp (C#) like this.. var
Sorry for the length of this post, but at the moment we are clueless,
Hey guys, before you guys say anything I have searched and can not find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.