I'm currently working on an application that involves reading pdf files into a variable and passing them to a server via http POST method.

On Linux, everything is fine because I can use cat and popen:

pdf = os.popen('cat testpdf.pdf').read() #read pdf data in Linux

However, in Windows, the DOS equivalent of cat called "type" is giving me garbage for pdf values.

My questions:
Is there a way to safely read a pdf values using DOS commands?
If not, how could I store a pdf in a single variable using Python?

Thanks

Recommended Answers

All 2 Replies

Why not pdf = open("testpdf.pdf", "rb").read() ?

i didnt get get what is 'os' and when i wrote your program on linux, ireceived an error saying popen not defined and unknown 'os'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.