コード例 #1
0
def save_pptx_as_pdf(pdf_filename: Union[str, "LocalPath"],
                     pptx_filename,
                     overwrite: bool = False) -> bool:
    """
    :param pdf_filename: save_folder (including path) of new pdf file
    :param pptx_filename: save_folder (including path) of pptx file
    :return:
    """
    if not has_comptypes:
        print("Comptype module needed to save PDFs.")
        return False

    if os.path.isfile(pdf_filename) and not overwrite:
        print(
            f"File {pdf_filename} already exists. Set overwrite=True, if you want to overwrite file."
        )
        return False

    powerpoint = CreateObject("Powerpoint.Application")
    pp_constants = Constants(powerpoint)
    pres = powerpoint.Presentations.Open(pptx_filename)
    pres.SaveAs(str(pdf_filename), pp_constants.ppSaveAsPDF)
    pres.close()
    if powerpoint.Presentations.Count == 0:  # only close, when no other Presentations are open!
        powerpoint.quit()

    return True
コード例 #2
0
ファイル: acad_table.py プロジェクト: skysharkk/polystyrene
 def __init__(self, initial_point, scale, column_width, row_height, acad):
     self.initial_point = initial_point
     self.scale = scale
     self.column_width = column_width
     self.row_height = row_height
     self.__model_space = acad.doc.ModelSpace
     self.__constansts = Constants(acad.app)
     self.__table = None
コード例 #3
0
def PPTtoPDF(inputFileName, outputFileName, formatType=2):
    powerpoint = CreateObject('Powerpoint.Application')
    constants = Constants(powerpoint)
    powerpoint.Visible = 1

    if outputFileName[-3:] != 'pdf':
        outputFileName = outputFileName + ".pdf"
    deck = powerpoint.Presentations.Open(inputFileName)
    deck.SaveAs(outputFileName, constants.PpSaveAsPDF)
    deck.Close()
    powerpoint.Quit()
コード例 #4
0
ファイル: winspec.py プロジェクト: zhong-lab/code
def _initialize():
    '''
    Create objects. Associated constants will be available in the _const
    object. Note that it's not possible to request the contents of that;
    one has to look in the Python file generated with gen_py.
    '''
    global _exp, _app, _const, _spec_mgr, _spec
    _exp = CreateObject('WinX32.ExpSetup.2')
    _app = CreateObject('WinX32.Winx32App.2')
    _const = Constants(_exp)
    _spec_mgr = CreateObject('WinX32.SpectroObjMgr')
    _spec = _spec_mgr.Current
    _spec.Process(_const.SPTP_INST_LOADCONFIGURATION)
コード例 #5
0
ファイル: winspec.py プロジェクト: GeigerGroup/SFGacquisition
    def __init__(self):
        '''
        Initialize communications with winspec program using Microsoft COM.
        Create objects. Associated constants will be available in the _const
        object. Note that it's not possible to request the contents of that;
        one has to look in the Python file generated with gen_py.
        '''

        self.exp = CreateObject('WinX32.ExpSetup.2')
        self.app = CreateObject('WinX32.Winx32App.2')
        self.const = Constants(self.exp)
        self.spec_mgr = CreateObject('WinX32.SpectroObjMgr')
        self.spec = self.spec_mgr.Current
        self.spec.Process(self.const.SPTP_INST_LOADCONFIGURATION)
コード例 #6
0
def PPTtoPDFNote(inputFileName, outputFileName, formatType=32):
    powerpoint = CreateObject('Powerpoint.Application')
    constants = Constants(powerpoint)
    powerpoint.Visible = 1

    if outputFileName[-3:] != 'pdf':
        outputFileName = outputFileName + ".pdf"
    deck = powerpoint.Presentations.Open(inputFileName)
    deck.ExportAsFixedFormat(
        outputFileName,
        constants.ppFixedFormatTypePDF,
        constants.ppFixedFormatIntentPrint,
        False,  # No frame
        constants.ppPrintHandoutHorizontalFirst,
        constants.ppPrintOutputNotesPages,
        constants.ppPrintAll)
    deck.Close()
    powerpoint.Quit()
コード例 #7
0
def save_pptx_as_png(save_folder: Union[str, "LocalPath"],
                     pptx_filename: str,
                     overwrite_folder: bool = False) -> bool:
    if not has_comptypes:
        print("Comptype module needed to save PNGs.")
        return False

    if os.path.isdir(save_folder) and not overwrite_folder:
        print(
            f"Folder {save_folder} already exists. "
            f"Set overwrite_folder=True, if you want to overwrite folder content."
        )
        return False

    powerpoint = CreateObject("Powerpoint.Application")
    pp_constants = Constants(powerpoint)

    pres = powerpoint.Presentations.Open(pptx_filename)
    pres.SaveAs(str(save_folder), pp_constants.ppSaveAsPNG)
    pres.close()
    if powerpoint.Presentations.Count == 0:  # only close, when no other Presentations are open!
        powerpoint.quit()
    return True
コード例 #8
0
#生成一百以内带退位减法 带进位加法

from comtypes.client import CreateObject,Constants
import random


app = CreateObject("Excel.Application")
excel_constants = Constants(app)

template_file = "g:/口算作业模板.xlsx"
out_dir = "g:\\"
out_name = out_dir+"口算"

max_number = 100
ratio_sub = 0.6 #减法题的比例
ratio_carry = 0.8 # 进退位比例
total_page = 40 # 总页数
seciton_per_page = 2 #每页的小节数
row_per_section = 10 #每页的行数
col_per_section = 3 #每页的列数
row_starts=[2, 16]

total_add_with_carry = 0 #带进位加法题目数
total_add_with_no_carry=0 #不带进位加法题目数
total_sub_decomposition = 0 #带退位减法题目数
total_sub_no_decomposition=0 #不带退位减法题目数

workbook = app.Workbooks.open(template_file)
# print(workbook.ActiveSheet.Cells(1,1).Value())

random.seed()
コード例 #9
0
v.X = 5

script = CreateObject('FeiTadHandPanels.TadHandPanelsBrick.1')
script.value

val = 0
script.TemperatureControl.RefrigerantLevel(val)

script = CreateObject("peouicStemAutoTuning.StemAutoTuningClusterControl")

script.

script.IPiaControl.GetDeviceCount()
pos =script.Stage.Position
pos.X

b = Constants(script)
b
b.hoSingleTilt
script.Stage.Goto(pos, TEMScripting.StageAxes )
v.X

)
engine = CreateObject("ESVision.Application")

acq = engine.AcquisitionManager().acquire()
acq

engine.GetRowCount(3)
engine.Exit()
コード例 #10
0
ファイル: acad_table.py プロジェクト: skysharkk/polystyrene
    def set_vertical_line_weight(self, position, weight):
        self.__set_line_weight(
            position,
            self.__constansts.acVertLeft + self.__constansts.acVertRight,
            weight)

    def set_vert_and_horz_line_weight(self, position, weight):
        self.__set_line_weight(
            position,
            self.__constansts.acVertLeft + self.__constansts.acVertRight +
            self.__constansts.acHorzBottom + self.__constansts.acHorzTop,
            weight)

    def create_table(self, line_weight):
        self.__add_table_to_ms()
        self.__change_table_sizes()
        for col_index in range(len(self.column_width)):
            for row_index in range(len(self.row_height)):
                print(row_index, col_index)
                if row_index == 0:
                    self.set_vert_and_horz_line_weight([row_index, col_index],
                                                       line_weight)
                self.set_vertical_line_weight([row_index, col_index],
                                              line_weight)


table = AcadTable(array("d", [0, 0, 0]), 40, c_s, r_h, acad)

table.create_table(60)
constants = Constants(acad.app)
コード例 #11
0
from comtypes.client import CreateObject,Constants
from easygraphics import dialog as dlg

import os
from pathlib import Path



app = CreateObject("Powerpoint.Application")
pp_constants = Constants(app)

dir_path = dlg.get_directory_name("请选择要转换的目录")

path = Path(dir_path)

for entry in path.iterdir():
    if not entry.is_file():
        continue
    print()
    filename = str(path.absolute())+os.sep+entry.name.lower()
    if filename.endswith(".ppt") or filename.endswith(".pptx"):
        print(filename)
        newname = newname.replace(".pptx",".pdf")
        newname = filename.replace(".ppt",".pdf")
        presentation = app.Presentations.Open(filename)
        presentation.SaveAs(newname, pp_constants.ppSaveAsPDF)
        presentation.Close()

app.Quit()
コード例 #12
0
from comtypes.client import CreateObject,Constants
from easygraphics import dialog as dlg

import os
from pathlib import Path



app = CreateObject("Word.Application")
word_constants = Constants(app)

dir_path = dlg.get_directory_name("请选择要转换的目录")

path = Path(dir_path)

for entry in path.iterdir():
    if not entry.is_file():
        continue
    print()
    filename = str(path.absolute())+os.sep+entry.name.lower()
    if filename.endswith(".doc") or filename.endswith(".docx"):
        print(filename)
        newname = filename.replace(".docx",".pdf")
        newname = filename.replace(".doc",".pdf")
        presentation = app.Documents.Open(filename)
        presentation.SaveAs2(newname, word_constants.wdFormatPDF)
        presentation.Close()

app.Quit()