This option will abort the conversion if no Start unoconv as listener for unoconv clients to connect to.īy default if no listener is running, unoconv will launch its own (temporary) listener Set specific import filters options (related to the used LibreOffice import filter Replace user-defined text field with value You can get a list of possible outputįormats per document type by using the -show option. Specify the output format for the document. for the PDF output filter one can specify: -e PageRange=1-2 Set specific export filter options (related to the used LibreOffice filter).Įg. Possible document typesĪre: document, graphics, presentation, spreadsheet. Specify the LibreOffice document type of the backend format. Or used by the listener to make LibreOffice listen.ĭefault connection string is "socket,host=localhost,port=2002 urp StarOffice.ComponentContext" UNO connection string to be used by the client to connect to an LibreOffice instance, “listener” instance to use for subsequent connections or even for remote connections. Therefore if it cannotįind one, it will start its own instance for temporary usage. Unoconv uses the LibreOffice’s UNO bindings for non-interactive conversion of documentsĪnd therefore needs an LibreOffice instance to communicate with. Import, to any file format that LibreOffice is capable of exporting. Unoconv is a command line utility that can convert any file format that LibreOffice can Newname = os.path.join(outputdir,newname)įiles = glob.glob(os.path.join(dir,"*.Unoconv - convert any document from and to any LibreOffice supported format Outputdir = r"C:\Users\Paul\Documents\web\ykfp\Par16\Presentations\pdf" I suppose if you wanted to avoid overwrite, you would have to use try-except somehow. By default, the SaveAs overwrites files in the output directory if they already exist, which is fine by me. I tried a couple times to get lines 13 -15 combined into one line, but I don't have time for that kind of elegance. Now the pdf files are written to a different folder, outputdir. #for file in [ ppt for ppt in os.listdir(dir)įiles = glob.glob(os.path.join(dir,"*.ppt*")) Now if I can just direct the output files to a different folder, I'll be done.ĭir = r"C:\Users\Paul\Documents\web\ykfp\Par16\Presentations\YBSMC 2016 Thursday" Your suggestion to change ppt? to ppt worked well to pick up both the old and the new file extensions. PowerPoint opens up, shows a little "publishing" progress bar for each input file, then Powerpoint shuts down. I'll read up on this.) So I replaced the sys.argv with my dir variable in line 25, and it ran. (Still, I don't understand entirely how this magic works. I set the path explicitly, then got side tracked with a for loop to test the list contents, lines 18 - 23, now commented out, and when that part showed me a good list of files, I almost put lines 25- 27 in the for loop, but then thought, hey that's what the glob.glob part is supposed to do. Thanks, Darren, that's a lot like what I came up with on my own. But it seemed to run to completion, giving "returned exit code 0" in the PythonWin bottom bar, but I can't find any output pdf file on my system. Running the script in pythonwin made it easier to insert an input file name as argv, and I didn't hit any of the win32 errors. I'm running ArcGIS 10.3.1 on a 64 bit Windows system, so it looks like python 2.7.8, so I tried the install of win32 2.7 32 bit. Looking through posts at Geonet, I found that I was having this problem with win32 back in 2006, and the easy way out is to run it in PythonWin. Newname = os.path.splitext(filename) ".pdf"ĭeck = (filename)įiles = glob.glob(os.path.join(sys.argv,"*.ppt?"))įirst I tried running the script in IDLE, but first hit No module named, then after I installed pywin extensions for python 27, 32 bit, I got ImportError: No module named win32api. If I can see this run once then I can extend it to loop through the whole folder and write to different output folder. I have a couple folders of PowerPoint files that I need to convert to PDF files, and I thought it would help me practice some python to see if I could script this task. This isn't a GIS question, but I thought maybe someone could help.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |