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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:42:06+00:00 2026-06-14T04:42:06+00:00

I am trying to read a pdf from a url without downloading and then

  • 0

I am trying to read a pdf from a url without downloading and then i am trying to flatten it .

This is the code :

import java.io.FileOutputStream;

import com.lowagie.text.pdf.AcroFields;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;

public class FormFillAndMakeItFlattenPDF {
   public static void main(String[] args) {
      try {
         PdfReader reader = new PdfReader("http://www.irs.gov/pub/irs-pdf/fw4.pdf");
         PdfStamper stamp2 = new PdfStamper(reader, new FileOutputStream("C:\\Flattened.pdf"));
         AcroFields form2 = stamp2.getAcroFields();
         stamp2.setFormFlattening(true);
         stamp2.close();
      }
      catch (Exception de) {
         de.printStackTrace();
      }
   }
}

However, this is throwing an error/exception . This is the stacktrace :

    java.net.ConnectException: Connection timed out: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:352)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:214)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:201)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:377)
    at java.net.Socket.connect(Socket.java:530)
    at java.net.Socket.connect(Socket.java:480)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:406)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:541)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:245)
    at sun.net.www.http.HttpClient.New(HttpClient.java:318)
    at sun.net.www.http.HttpClient.New(HttpClient.java:335)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:832)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:773)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:698)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1021)
    at java.net.URL.openStream(URL.java:1009)
    at com.lowagie.text.pdf.RandomAccessFileOrArray.<init>(Unknown Source)
    at com.lowagie.text.pdf.RandomAccessFileOrArray.<init>(Unknown Source)
    at com.lowagie.text.pdf.PRTokeniser.<init>(Unknown Source)
    at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)
    at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)
    at FormFillAndMakeItFlattenPDF.main(FormFillAndMakeItFlattenPDF.java:18)

Can anybody tell me , what i am doing wrong here ?

  • 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-14T04:42:08+00:00Added an answer on June 14, 2026 at 4:42 am

    If the problem happens because of proxy, call this at application startup.

    System.setProperty("http.proxyHost", Config.PROXY_HOST);
    System.setProperty("http.proxyPort", Config.PROXY_PORT);
    

    where you change Config.X to your system values.

    Note: for https you need to add similar lines with https.proxyHost and https.proxyPort

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

Sidebar

Related Questions

I'm trying to read a pdf file and get all hyperlinks from this file.
I have this wireframe I am working from: http://problemio.com/wireframe.pdf I am trying to make
I'm trying to implement this: from https://docs.google.com/viewer?url=http://www.tinaja.com/glib/bezdist.pdf&pli=1 The following BASIC program uses the method
I am trying to read some XML code from a website, and am having
I am trying to silent print PDF files from within a java application (more
I'm trying to Downloading pdf from server and displaying it as it is. I
I'm trying to insert and read qrcode's from PDF files. To create/read qr codes
Im trying to use Adobe reader to read pdf files downloaded from the server
I am trying to read multiple files (can be of any format i.e. pdf,
Im trying to read a column of String values from my DB. Im trying

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.