I've got this working on this automated python script that edits a PPTX template and converts it to PDF, however this only works in windows operating env as the dependency required for this to work is using win32com.client. However I'll be porting the script to linux based so it will not work.
Any suggestion/work around to take for the conversion of PPT -> PDF in python without using win32com and apose.slides.
P.S. I'm also unable to install libreoffice on linux due to insufficient privileges
Related
I am looking for a way to convert a docx to PDF using Python in Linux. So far, all I have found that works it is using Windows, is there a way to do it in Python without using libreoffice?
I've written a program with python to display a graph with matlab library which displays it in a new window with python3. I would like to use an online compiler (https://www.tutorialspoint.com/execute_python_online.php) so that I would be able to share the program, but because this requires matlab to open a window, the online compiler fails. How am I able to solve this?
Can you just send the entire .py file to someone else so they can run it on their computer? As far as I know, there is no option for running Python code online without requiring a download / installation that is free where you can also install libraries (like matplotlib).
Does anyone know of a way to read and write the National Instruments binary file type (TDMS) in python under linux? I know that NI has a C DLL available, but I don't know how to access that through python, or if I even can do so under linux.
It looks like TDMS isn't directly supported under Linux (see here).
Your options currently are to use the G-based functions directly in LabVIEW (It's possible that you can wrap them in a .so file), calling LabVIEW from Python, or building your own file parser from the TDMS spec.
Sorry, no really easy options.
Edit: It looks like there may be an open source project to try to do this at http://sourceforge.net/projects/pytdms/. Worth a try, at least.
You have to install the python version 2.7 (thats the only one that is working with the tdms package for labview atleast)
Sudo pip install npTDMS
Link to the tdms package page
and just follow the example on the page.
I want to write a python script to convert PNG's into 2-page pdfs (i.e. 2 PNGs per PDF). The software needs to run on both a Mac and Windows 7.
My current solution is using ReportLab, but that doesn't install easily on a Mac. According to its website, it only has a compiled version for Windows. It has a cross-platform version that requires a C compiler to install.
Is there a better way to do this (so that I don't have to install a C compiler on the Mac)? Should I use a different library, or a different language entirely? As long as I can call the program from a python script, I could use any language for the pdf creation. Or, is there a very straightforward (i.e a non-programmer could install it) C compiler that I could install on a Mac?
What do you recommend?
The unix program convert can help you for conversion.
convert file.png file.pdf
But you said you want to have it under windows too. PIL imaging library has a PDF module. you should try a simple
pilconvert file.png file.pdf
to put more than one image you can play with the library which is quite flexible for resizing, stitching, etc. It is also available for mac and windows
Update 2011-02-15
On my macosx, I have installed reportlab without difficulties.
% sudo easy_install reportlab
Searching for reportlab
Reading http://pypi.python.org/simple/reportlab/
Reading http://www.reportlab.com/
Best match: reportlab 2.5
Downloading http://pypi.python.org/packages/source/r/reportlab/reportlab-2.5.tar.gz#md5=cdf8b87a6cf1501de1b0a8d341a217d3
Processing reportlab-2.5.tar.gz
So you could use a combination of PIL and Reportlab for your own needs.
Reportlab is one of the good tools for generating pdfs. If you can use it for your purposes, it is better to stick with it. For installation on MAC, I see that darwinports have a port for Reportlab called py-reportlab. Follow the instructions to install it using portage, it will install the dependencies by itself.
PyCairo could be a good alternative. You'll have full control and less dependencies, but reportlab is a lot simplier.
Why anyone hasn't tried this??
If you are not much concern about the quality, try the following solution.
import PIL.Image
filepath = "temp.png"
newfilename = 'our.pdf'
im = PIL.Image.open(filepath)
im.save(newfilename, "PDF", quality=100)
I'm attempting to use Python to convert a multi-page PDF into a series of JPEGs. I can split the PDF up into individual pages easily enough with available tools, but I haven't been able to find anything that can covert PDFs to images.
PIL does not work, as it can't read PDFs. The two options I've found are using either GhostScript or ImageMagick through the shell. This is not a viable option for me, since this program needs to be cross-platform, and I can't be sure either of those programs will be available on the machines it will be installed and used on.
Are there any Python libraries out there that can do this?
ImageMagick has Python bindings.
Here's whats worked for me using the python ghostscript module (installed by '$ pip install ghostscript'):
import ghostscript
def pdf2jpeg(pdf_input_path, jpeg_output_path):
args = ["pdf2jpeg", # actual value doesn't matter
"-dNOPAUSE",
"-sDEVICE=jpeg",
"-r144",
"-sOutputFile=" + jpeg_output_path,
pdf_input_path]
ghostscript.Ghostscript(*args)
I also installed Ghostscript 9.18 on my computer and it probably wouldn't have worked otherwise.
You can't avoid the Ghostscript dependency. Even Imagemagick relies on Ghostscript for its PDF reading functions. The reason for this is the complexity of the PDF format: a PDF doesn't just contain bitmap information, but mostly vector shapes, transparencies etc.
Furthermore it is quite complex to figure out which of these objects appear on which page.
So the correct rendering of a PDF Page is clearly out of scope for a pure Python library.
The good news is that Ghostscript is pre-installed on many windows and Linux systems, because it is also needed by all those PDF Printers (except Adobe Acrobat).
If you're using linux some versions come with a command line utility called 'pdftopbm' out of the box. Check out netpbm
Perhaps relevant: http://www.swftools.org/gfx_tutorial.html