File tree Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Package/Script Name: ppt2pdf
2
+
3
+ * PPT to PDF Converter with Python
4
+ * For Windows users & Linux ones.
5
+ *
6
+
7
+
8
+ # Setup instructions
9
+ ## For Windows
10
+
11
+ ## Note that ` comtypes ` is only available for Windows.
12
+
13
+ * Function ` PPTtoPDF() `
14
+ * Fucntion ` PPTtoPDFNote() `
15
+
16
+ ** How to use :**
17
+
18
+ ``` console
19
+ PPTtoPDF('InputFile.pptx', 'OutputFile.pdf')
20
+ ```
21
+ ---
22
+ ``` console
23
+ PPTtoPDFNote('InputFile.pptx', 'Output_with_Note.pdf')
24
+ ```
25
+
26
+
27
+ ## For Linux
28
+
29
+ * Install requirements
30
+
31
+ ``` console
32
+ sudo apt install unoconv
33
+ pip install tqdm
34
+ pip install glob
35
+ ```
36
+
37
+ # Output
38
+
39
+ * The ` PDF/PDFNote ` file
40
+
41
+
42
+ # Author:
43
+
44
+ ## [ Ayoub Berdeddouch] ( https://github.com/ayoub-berdeddouch )
Original file line number Diff line number Diff line change
1
+ # import libraries
2
+ import glob
3
+ import tqdm
4
+ import os
5
+
6
+ PATH = "INPUT FOLDER"
7
+ # extension
8
+ et = "pptx" # or ppt
9
+ files = [f for f in glob .glob (PATH + "/**/*.{}" .format (et ), recursive = True )]
10
+ for f in tqdm .tqdm (files ):
11
+ command = "unoconv -f pdf \" {}\" " .format (f )
12
+ os .system (command )
Original file line number Diff line number Diff line change
1
+ # Note that comtypes is only available for Windows.
2
+ from comtypes .client import CreateObject , Constants
3
+
4
+
5
+ # Function PPTtoPDF
6
+ def PPTtoPDF (inputFileName , outputFileName , formatType = 2 ):
7
+ powerpoint = CreateObject ('Powerpoint.Application' )
8
+ constants = Constants (powerpoint )
9
+ powerpoint .Visible = 1
10
+
11
+ if outputFileName [- 3 :] != 'pdf' :
12
+ outputFileName = outputFileName + ".pdf"
13
+ deck = powerpoint .Presentations .Open (inputFileName )
14
+ deck .SaveAs (outputFileName , constants .PpSaveAsPDF )
15
+ deck .Close ()
16
+ powerpoint .Quit ()
17
+
18
+
19
+ # Function PPTtoPDFNote
20
+ def PPTtoPDFNote (inputFileName , outputFileName , formatType = 32 ):
21
+ powerpoint = CreateObject ('Powerpoint.Application' )
22
+ constants = Constants (powerpoint )
23
+ powerpoint .Visible = 1
24
+
25
+ if outputFileName [- 3 :] != 'pdf' :
26
+ outputFileName = outputFileName + ".pdf"
27
+ deck = powerpoint .Presentations .Open (inputFileName )
28
+ deck .ExportAsFixedFormat (
29
+ outputFileName ,
30
+ constants .ppFixedFormatTypePDF ,
31
+ constants .ppFixedFormatIntentPrint ,
32
+ False , # No frame
33
+ constants .ppPrintHandoutHorizontalFirst ,
34
+ constants .ppPrintOutputNotesPages ,
35
+ constants .ppPrintAll
36
+ )
37
+ deck .Close ()
38
+ powerpoint .Quit ()
You can’t perform that action at this time.
0 commit comments