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 8445087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:34:11+00:00 2026-06-10T09:34:11+00:00

I am creating a PDF reader in java. For reading PDF files i am

  • 0

I am creating a PDF reader in java. For reading PDF files i am using iText library. I have a sample code to read the PDF files but i don’t know how to display the iText Image object in a JFrame.Below is the code to read a PDF file.

import java.io.FileOutputStream;
import java.io.IOException;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.PdfImportedPage;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfWriter;

public class ReadAndUsePdf {
private static String INPUTFILE = "c:/temp/FirstPdf.pdf";
private static String OUTPUTFILE = "c:/temp/ReadPdf.pdf";

public static void main(String[] args) throws DocumentException,
        IOException {
    Document document = new Document();

    PdfWriter writer = PdfWriter.getInstance(document,
            new FileOutputStream(OUTPUTFILE));
    document.open();
    PdfReader reader = new PdfReader(INPUTFILE);
    int n = reader.getNumberOfPages();
    PdfImportedPage page;
    // Go through all pages
    for (int i = 1; i <= n; i++) {
        // Only page number 2 will be included
        if (i == 2) {
            page = writer.getImportedPage(reader, i);
            Image instance = Image.getInstance(page); //how to show this object in a JFrame
            document.add(instance);
        }
    }
    document.close();

}

}
  • 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-10T09:34:12+00:00Added an answer on June 10, 2026 at 9:34 am

    I have the exactly same problem, and I solved it by using ICEPdf to render the PDF in Swing, and iText to manipulate it.

    Possible duplication: Can I use iText to render PDF in my Swing application?

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

Sidebar

Related Questions

I am creating some PDF reports using iText in Java. According to the requirements,
I'm currently converting some legacy code to create PDF files using iTextSharp. We're creating
I'm creating PDF files with PHP using TCPDF. I have a small problem with
I have implemented pdf creation, http://bakery.cakephp.org/articles/kalileo/2010/06/08/creating-pdf-files-with-cakephp-and-tcpdf but in my logic, there is a link
I'm using html2fpdf for creating PDF documents. Now once I have created that, I
I'm creating a PDF with iText version 2.1.0. I have to create a detail
i have a program that takes some time creating pdf files i would like
I'm using code to create a PDF File. Works. But: I want my whole
I am using PHP code for creating .pdf file and I am filing forms
I am creating a pdf document using C# code in my process. I need

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.