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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:17:59+00:00 2026-06-06T02:17:59+00:00

I have a little python script that I am using to download a whole

  • 0

I have a little python script that I am using to download a whole bunch of PDF files for archiving. The problem I have is that when I download the files, they appear correctly under the correct title, but they are the wrong size and they can’t be opened by Acrobat, which fails with an error message saying Out of memory or Insufficient data for an image or some other arbitrary Acrobat error. Viewing the content of the page in a text editor looks a bit like a PDF document, by which I mean it is incomprehensible in general but with a few fragments of text and markup, including PDF identifiers.

The code to download the file is this:

def download_file( file_id):
    folder_path = ".\\pdf_files\\"
    file_download="http://myserver/documentimages.asp?SERVICE_ID=RETRIEVE_IMAGE&documentKey="    
    file_content = urllib.urlopen(file_download+file_id, proxies={})
    file_local = open( folder_path + file_id + '.pdf', 'w' )
    file_local.write(file_content.read())
    file_content.close()
    file_local.close()

If the same file is downloaded through a browser it looks fine, but is also larger on the disk. I am guessing that the problem might be to do with the encoding of the file when it is saved?

  • 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-06T02:18:00+00:00Added an answer on June 6, 2026 at 2:18 am

    You need to write it as a binary file so:

    file_local = open( folder_path + file_id + '.pdf', 'wb' )

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

Sidebar

Related Questions

I have af python script that download attchments from a POP3 mailbox. But I
I have a little python script that pulls emails from a POP mail address
I have a python script that checks a certain folder for new files and
Greetings. I have written a little python script that calls MySQL in a subprocess.
I have a python script that is writing text to images using the PIL.
I have a little problem with local variables and python (2.7). I have a
So I have a python script that I'd prefer worked on python 3.2 and
I have created a little Python egg (with setuptools) that I want to install
I wrote a little PyGTK app: Workcycler Now I have the problem that I
I've been using python for years, but I have little experience with python web

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.