Linux pptx to pdf

Transforming PPTX Files with Notes to PDF using Shell

An alternative solution is to employ AppleScript to transform PowerPoint files into PDF documents. You may refer to my response to a similar query on how to execute this. Begin by opening Script Editor, selecting New Document, and copying the script. Make it executable using the command provided. Afterward, open Terminal and navigate to the folder where the PowerPoint files are stored to convert them to PDF documents using the command provided. Alternatively, if the $HOME/bin directory is included in your $PATH, you may simply use the shorter command.

Linux command to convert powerpoint (pptx) to pdf

If you possess the code LibreOffice , you can execute this instruction:

soffice —headless —convert-to pdf inputfile.pptx

Tools to extract text from powerpoint pptx in linux?, If you can process the files in bash , this one-liner will unpack all the text: unzip -qc «$1» ppt/slides/slide*.xml | grep -oP ‘(?).*?(?

How to Convert PowerPoint to PDF (PPT to PDF)

How can I automatically convert PowerPoint to PDF?

No external tool is required since PowerPoint can export a presentation in PDF format, as you mentioned. By using some scripting, you can attain your desired outcome. I have provided a VB Script below, which you can use by creating a file with a «.vbs» extension and pasting the code.

 CSCRIPT ppt.vbs "input file name" "output file name" 
  • In case the name(s) include spaces, it will be necessary to enclose them in quotation marks.
  • In case you do not mention the location for the output file, PowerPoint will automatically save it in the Documents folder.

Inline links have been incorporated for easy reference to different components.

Option Explicit Sub WriteLine ( strLine ) WScript.Stdout.WriteLine strLine End Sub ' http://msdn.microsoft.com/en-us/library/office/aa432714(v=office.12).aspx Const msoFalse = 0 ' False. Const msoTrue = -1 ' True. ' http://msdn.microsoft.com/en-us/library/office/bb265636(v=office.12).aspx Const ppFixedFormatIntentScreen = 1 ' Intent is to view exported file on screen. Const ppFixedFormatIntentPrint = 2 ' Intent is to print exported file. ' http://msdn.microsoft.com/en-us/library/office/ff746754.aspx Const ppFixedFormatTypeXPS = 1 ' XPS format Const ppFixedFormatTypePDF = 2 ' PDF format ' http://msdn.microsoft.com/en-us/library/office/ff744564.aspx Const ppPrintHandoutVerticalFirst = 1 ' Slides are ordered vertically, with the first slide in the upper-left corner and the second slide below it. Const ppPrintHandoutHorizontalFirst = 2 ' Slides are ordered horizontally, with the first slide in the upper-left corner and the second slide to the right of it. ' http://msdn.microsoft.com/en-us/library/office/ff744185.aspx Const ppPrintOutputSlides = 1 ' Slides Const ppPrintOutputTwoSlideHandouts = 2 ' Two Slide Handouts Const ppPrintOutputThreeSlideHandouts = 3 ' Three Slide Handouts Const ppPrintOutputSixSlideHandouts = 4 ' Six Slide Handouts Const ppPrintOutputNotesPages = 5 ' Notes Pages Const ppPrintOutputOutline = 6 ' Outline Const ppPrintOutputBuildSlides = 7 ' Build Slides Const ppPrintOutputFourSlideHandouts = 8 ' Four Slide Handouts Const ppPrintOutputNineSlideHandouts = 9 ' Nine Slide Handouts Const ppPrintOutputOneSlideHandouts = 10 ' Single Slide Handouts ' http://msdn.microsoft.com/en-us/library/office/ff745585.aspx Const ppPrintAll = 1 ' Print all slides in the presentation. Const ppPrintSelection = 2 ' Print a selection of slides. Const ppPrintCurrent = 3 ' Print the current slide from the presentation. Const ppPrintSlideRange = 4 ' Print a range of slides. Const ppPrintNamedSlideShow = 5 ' Print a named slideshow. ' http://msdn.microsoft.com/en-us/library/office/ff744228.aspx Const ppShowAll = 1 ' Show all. Const ppShowNamedSlideShow = 3 ' Show named slideshow. Const ppShowSlideRange = 2 ' Show slide range. ' ' This is the actual script ' Dim inputFile Dim outputFile Dim objPPT Dim objPresentation Dim objPrintOptions Dim objFso If WScript.Arguments.Count <> 2 Then WriteLine "You need to specify input and output files." WScript.Quit End If inputFile = WScript.Arguments(0) outputFile = WScript.Arguments(1) Set objFso = CreateObject("Scripting.FileSystemObject") If Not objFso.FileExists( inputFile ) Then WriteLine "Unable to find your input file " & inputFile WScript.Quit End If If objFso.FileExists( outputFile ) Then WriteLine "Your output file (' & outputFile & ') already exists!" WScript.Quit End If WriteLine "Input File: " & inputFile WriteLine "Output File: " & outputFile Set objPPT = CreateObject( "PowerPoint.Application" ) objPPT.Visible = True objPPT.Presentations.Open inputFile Set objPresentation = objPPT.ActivePresentation Set objPrintOptions = objPresentation.PrintOptions objPrintOptions.Ranges.Add 1,objPresentation.Slides.Count objPrintOptions.RangeType = ppShowAll ' Reference for this at http://msdn.microsoft.com/en-us/library/office/ff746080.aspx objPresentation.ExportAsFixedFormat outputFile, ppFixedFormatTypePDF, ppFixedFormatIntentScreen, msoTrue, ppPrintHandoutHorizontalFirst, ppPrintOutputSlides, msoFalse, objPrintOptions.Ranges(1), ppPrintAll, "Slideshow Name", False, False, False, False, False objPresentation.Close ObjPPT.Quit 

You have the option to choose from a variety of PDF printer drivers, including Adobe Distiller or any of the numerous affordable or open-source alternatives available.

Читайте также:  Посмотреть время загрузки linux

The 2007 version of Office PowerPoint Viewer offers a command line option marked as /p that enables the printing of a PowerPoint document on the default printer.

Send the presentation to a printer, and print the file. Example: "c:\program files\microsoft office\office12\PPTVIEW.exe" /P "Presentation.pptx" This example prints the Presentation.pptx file. 

It is probable that you would need to make the PDF Printer your default printer.

Instead of purchasing Adobe Acrobat along with Adobe Distiller, I suggest using PDFCreator as it is free and allows automated saving of output files with customized options. By doing so, you can convert PowerPoint files to PDF through a command line method without making any additional payments to Microsoft or Adobe.

Is there a command-line tool for converting html files to pdf? [duplicate], pandoc is a great command-line tool for file format conversion. The disadvantage is for PDF output, you’ll need LaTeX. The usage is

How do I script Powerpoint to save a directory of PPTX files as PDFs?

With PowerPoint already installed, accomplishing this task is a breeze through Automator.

As I am using Office 2011, I am not certain if this would be compatible with the 2008 version.

Launch Automator and generate a fresh Folder Action. Select the directory where the PPTX files are located as the input folder.

Select «Convert Format of PowerPoint Presentations» from the Actions menu and opt for «Portable Document Format» as the new format.

Once you have saved your changes in Automator, you can simply close it to complete the task.

Every PPTX file that you save in the selected directory, regardless of whether it is pre-existing or newly created, will be transformed into a PDF version as a supplementary backup.

You can convert PowerPoint files to PDF documents using AppleScript, which I explained in my response to a comparable inquiry on this topic.

    Open Script Editor, select New Document and paste the script below. Make sure you adapt parts that are locale specific like «Sichern», «Vorschau» and the like to your local language . and check for the latest version at https://github.com/WolfgangFahl/ppt2pdf

on run (argv) log (count (argv)) if ((count of argv) < 2) then log "usage: ppt2pdf basepath [filenames]" else my ppt2Pdf(argv) end if end run -- -- convert PowerPoint to PDF on the given list of files -- on ppt2Pdf(fileNames) log "launching Powerpoint . " set pp to "Microsoft PowerPoint" tell application pp -- work on version 15.15 or newer launch set isfirst to true repeat with fileName in fileNames if isfirst then set basepath to fileName log "base path is " & basepath set isfirst to false else if fileName ends with ".ppt" or fileName ends with ".pptx" or fileName ends with ".pptm" then set filePath to basepath & "/" & fileName -- set filePath to POSIX path of fileAlias set pdfPath to my makeNewPath(filePath) log "trying to convert powerpoint file " & filePath & " to " & pdfPath open filePath -- save active presentation in pdfPath as save as PDF -- save in same folder -- https://macscripter.net/viewtopic.php?id=26342 --tell application "System Events" -- set listOfProcesses to (name of every process where background only is false) -- tell me to set selectedProcesses to choose from list listOfProcesses with multiple selections allowed --end tell --repeat with processName in selectedProcesses -- log processName --end repeat if not my chooseMenuItem(pp, "Datei", "Drucken. ") then error number -128 end if --my showUiElements(pp, "menu button") -- my waitFor(button whose description is "PDF", 5, 0.5) my choosePopUp(pp, "Layout für den Druck", "Notizen") my choosePopUp(pp, "Farbausgabeformat", "Farbe") --my chooseMenuButtonItem(pp, "PDF", "Als PDF sichern") local myTitle tell application "System Events" -- the magic of Applescript -- if you really want the title and not a reference to it you need to use an operator -- http://books.gigatux.nl/mirror/applescriptdefinitiveguide/applescpttdg2-CHP-12-SECT-5.html set myTitle to title of window 1 of process pp & "" end tell my chooseMenuButtonItem(pp, "PDF", "In Vorschau öffnen") delay 5 tell application "System Events" log "waiting for Vorschau to display " & myTitle set timeLeft to my waitForAppearWindow(myTitle, process "Vorschau", 30, 0.5) if timeLeft < 0 then log "Vorschau " & myTitle & " window didn't show up after 30 secs" error number -128 else log "Vorschau appeared with " & timeLeft & "secs left" tell process "Vorschau" delay 0.2 click menu item "Als PDF exportieren …" of menu 1 of menu bar item "Ablage" of menu bar 1 delay 0.5 -- CMD-SHIFT-G to set the export director -- https://dougscripts.com/itunes/itinfo/keycodes.php keystroke "g" using delay 0.2 tell sheet 1 of window (myTitle) tell sheet 1 -- dereference basePath local basePathStr set basePathStr to basepath & "" set value of first combo box to basePathStr delay 0.2 click button "Öffnen" delay 0.2 end tell click button "Sichern" set timeLeft to my waitForAppear(sheet 1, 3, 0.2) tell sheet 1 if timeLeft > 0 then click button "Ersetzen" end if end tell delay 5 keystroke "q" using end tell end tell end if end tell --tell application "System Events" -- set timeLeft to my waitForAppear("button", button "Sichern" of sheet 1 of sheet 1 of window 1 of process pp, 5, 0.5) -- if timeLeft < 0 then -- log "Sichern button didn't show up after 5 secs" -- error number -128 -- end if -- click button "Sichern" of sheet 1 of sheet 1 of window 1 of process pp --end tell --tell application "System Events" -- delay 0.5 -- try -- set timeLeft to my waitForAppear("button", button "Ersetzen" of sheet 1 of sheet 1 of sheet 1 of window 1 of process pp, 5, 0.5) -- if timeLeft < 0 then -- log "Ersetzen button didn't show up after 5 secs" -- error number -128 -- end if -- click button "Ersetzen" of sheet 1 of sheet 1 of sheet 1 of window 1 of process pp -- end try --end tell log "done . " -- close filePath end if end if end repeat -- still in tell powerpoint context --tell application "System Events" -- delay 0.5 -- try -- set timeLeft to my waitForVanish("window", window "Sichern" of process pp, 60, 1) -- if timeLeft < 0 then -- log "print dialog didn't vanish after 60 secs" -- error number -128 -- end if -- end try --end tell quit end tell end ppt2Pdf on showElement(uiElem) local className set className to class of uiElem as string log (((«class pDSC» of uiElem as string) & "=" & value of uiElem as string) & "(" & className) & ")" end showElement -- -- show all UI elements -- on showUiElements(appName, filterClassName) tell application "System Events" tell process appName tell (1st window whose value of attribute "AXMain" is true) repeat with uiElem in entire contents of it as list try local className set className to class of uiElem as string if filterClassName is missing value or className is filterClasssname then log (((description of uiElem as string) & "=" & value of uiElem as string) & "(" & className) & ")" end if end try end repeat end tell end tell end tell end showUiElements -- -- wait for the given element to appear -- on waitForAppearWindow(elementName, parentElement, time, slice) set timeLeft to time set appeared to false repeat until (appeared) or timeLeft ≤ 0 try set appeared to window elementName of parentElement exists end try delay slice log "." set timeLeft to timeLeft - slice end repeat log timeLeft return timeLeft end waitForAppearWindow -- -- wait for the given element to appear -- on waitForAppear(element, time, slice) set timeLeft to time set appeared to false repeat until (appeared) or timeLeft ≤ 0 try set appeared to element exists end try delay slice log "." set timeLeft to timeLeft - slice end repeat log timeLeft return timeLeft end waitForAppear --- --- wait for the given element to vanish --- on waitForVanish(element, time, slice) set timeLeft to time try repeat while (exists element) and timeLeft >0 delay slice log "." set timeLeft to timeLeft - slice end repeat end try log timeLeft return timeLeft end waitForVanish on chooseMenuButtonItem(appName, buttonName, itemName) tell application "System Events" tell process appName tell window 1 local win1 set win1 to it tell sheet 1 log "choosing " & itemName & " of menu button " & buttonName tell menu button buttonName click delay 0.1 tell menu 1 click menu item itemName end tell end tell end tell end tell end tell end tell end chooseMenuButtonItem -- -- choose a popup -- on choosePopUp(appName, buttonName, itemName) tell application "System Events" tell process appName tell window 1 tell sheet 1 log "choosing " & itemName & " of pop up menu " & buttonName --repeat with pbutton in pop up buttons -- local pbutton1 -- set pbutton1 to pbutton -- log description of pbutton & "=" & value of pbutton --end repeat tell (1st pop up button whose description is buttonName) click it delay 0.5 pick menu item itemName of menu 1 end tell end tell end tell end tell end tell end choosePopUp -- -- https://developer.apple.com/library/archive/documentation/ -- LanguagesUtilities/Conceptual/MacAutomationScriptingGuide -- AutomatetheUserInterface.html#//apple_ref/doc/uid/TP40016239-CH69-SW17 -- on chooseMenuItem(theAppName, theMenuName, theMenuItemName) try -- Bring the target app to the front tell application theAppName activate end tell -- Target the app tell application "System Events" tell process theAppName -- Target the menu bar tell menu bar 1 -- Target the menu by name tell menu bar item theMenuName tell menu theMenuName -- Click the menu item log "clicking " & theMenuItemName click menu item theMenuItemName end tell end tell end tell end tell end tell return true on error return false end try end chooseMenuItem on makeNewPath(f) set t to f as string if t ends with ".pptx" or t ends with ".pptm" then return (text 1 thru -5 of t) & "pdf" else return (text 1 thru -4 of t) & "pdf" end if end makeNewPath 
#!/bin/bash # use current path as base path osascript $HOME/bin/ppt2pdf.scpt $(pwd) $@ 

To transform PowerPoint files into PDF documents, navigate to the folder where the PowerPoint files are stored using Terminal and execute the following command.

Читайте также:  Linux mint vista theme

If the directory $HOME/bin is included in your $PATH.

Источник

Convert ppt or pptx to pdf in linux with php

I want to convert ppt or pptx to pdf in linux with php and I am using following command Using LibreOffice:

exec('soffice --headless --convert-to pdf:"draw_pdf_Export" /home/test/public_html/converted/presentation1.ppt',$o1,$r1); 
exec("/usr/bin/openoffice.org -f pdf /home/yocook/public_html/converted/test.doc --outdir /home/yocook/public_html/converted",$output1,$ret1); 

Did you try to execute those commands by yourself in a terminal to see if the problem comes from PHP or not ?

also, you cannot trust ooo/lo return codes. they are always 0 in my experience, even when the most horrible errors (should have) happened — like e.g. calling a nonexistent macro.

I don’t have access to the terminal to execute the command directly as this is our test server and many projects are running under it. I will try to have the access first.

1 Answer 1

If you access it via webserver, your webserver wwwrun may not have sufficient permissions to look into the yocook directory.

Try executing the php file from terminal with the command: php convert.php (where convert.php is the name of your file)

if it succesfully works then it’s a permissions issue and you should use a public temp dir for your files. If it still doesn’t work try the commands directly in terminal and see if any errors occur, if it works perfectly try su wwwadmin and execute the command as wwwadmin and see what happens.

If it still works try to see in php.ini if the exec command is even allowed.

Источник

Оцените статью
Adblock
detector