def testCopy(): cdrObj = CDR( "D:\\github\\cdr\\mmxai\\src\\templates\\brochures\\画册-医疗-竖-001.cdr") cdrObj1 = CDR( "D:\\github\\cdr\\mmxai\\src\\templates\\brochures\\Backup_of_画册-医疗-竖-001.cdr" ) cdrObj.acrossCopyToLayer(cdrObj1, 6)
def testGroup(): cdrObj = CDR() layer = cdrObj.getLayer("秒秒学装饰") s1 = layer.FindShape("test1") s2 = layer.FindShape("test2") s3 = layer.FindShape("test3") s4 = layer.FindShape("test4") # 创建4个边界三角形 if s1 == None: s1 = cdrObj.drawDecorationTriangle("test1", {"background-color": [255, 0, 0]}, { "bottom": 300, "left": 600 }, 'lefttop') if s2 == None: s2 = cdrObj.drawDecorationTriangle("test2", {"background-color": [255, 0, 0]}, { "top": 300, "right": 600 }, 'rightbottom') if s3 == None: s3 = cdrObj.drawDecorationTriangle("test3", {"background-color": [255, 0, 0]}, { "top": 300, "right": 600 }, 'rightbottom') if s4 == None: s4 = cdrObj.drawDecorationTriangle("test4", {"background-color": [255, 0, 0]}, { "top": 300, "right": 600 }, 'rightbottom')
def paletteTest1(): cdrObj = CDR() paletteObj = cdrObj.accessPalette('my') cdrObj.setPletteEnabled(paletteObj) #启用 # 创建一个颜色对象,使用指定格式 color = cdrObj.createColorObj([110, 128, 255], 'unique_key', 'RGB') # 把颜色增加到调色板上 cdrObj.addPletteColor(paletteObj, color)
def setContent(pageIndex="", path=""): data = { 'logo': { 'pageIndex': 1, 'value': 'C:\\Users\\Administrator\\Desktop\\111\\1.png' } } CDR().set(data)
def drawDecorationTriangle(): # CDR().groupDecorationTriangle() CDR().drawDecorationTriangle("test", {"background-color": [255, 0, 0]}, { "bottom": 300, "left": 600 }, 'lefttop') CDR().drawDecorationTriangle("test", {"background-color": [255, 0, 0]}, { "bottom": 300, "right": 600 }, 'righttop') CDR().drawDecorationTriangle("test", {"background-color": [255, 0, 0]}, { "top": 300, "left": 600 }, 'leftbottom') CDR().drawDecorationTriangle("test", {"background-color": [255, 0, 0]}, { "top": 300, "right": 600 }, 'rightbottom')
def moveToMiddle(): cdrObj = CDR() # cdrObj.moveToLandscapeMiddle("测试1") # cdrObj.moveToLeft(obj) # cdrObj.moveToRight('测试1') # cdrObj.moveToTop('测试1') # cdrObj.moveToBottom('测试1') # cdrObj.moveToVerticalMiddle('测试1') cdrObj.moveToCenter('测试1')
def testPowerClip(): d1 = CDR() layer = d1.getLayer("秒秒学装饰") # 必须设置活动的layer,这样调用vb.exe才会在这个layer的内部 layer.Activate() imgShape = d1.addImage(layer, "C:\\Users\\Administrator\\Desktop\\111\\1.png") #设置单位像素 d1.doc.Unit = 5 ellipse = layer.CreateEllipse(100, 100, 500, 500) imgShape.AddToSelection() imgShape.AddToPowerClip(ellipse)
def combineTest(): cdrObj = CDR() obj = cdrObj.insertParaText( [0, 0, 120, 500], '测试1', '我是内容123123大1sdfasfsfsdf2312dfsadfsfsdf1111我是内容123123大1sdfasfsfsdf2312dfsadfsfsdf111111' ) cdrObj.setColor(obj, [255, 0, 0]) cdrObj.addFontSize(obj, 24) cdrObj.moveToCenter(obj) cdrObj.modifyParaText( obj, 'dfs123123大1sdfasfsfsdf2312dfsadfsfsdf11111我是内容123123大1sdfasfsfsdf2312dfsadfsfsdf11111我是内容123123大1sdfasfsfsdf2312dfsadfsfsdf11111我是内容123123大1sdfasfsfsdf2312dfsadfsfsdf11111我是内容123123大1sdfasfsfsdf2312dfsadfsfsdf11111', [5, 50, 100, 50], '', '') cdrObj.setFontSize(obj, 10)
def testSaveCDR(): cdrObj = CDR() # for thecolor in paletteObj.Colors(): # print(thecolor) standardColor = { "69_2_20_0": "深色背景", "1_0_0_0": "暮光之城色", "93_88_89_80": "仓色", "0_0_0_0": "白色", "100_88_47_61": "Stratos" # "6_4_4_0":"瓷色" } errorObj = cdrObj.standardizedColor(standardColor) print(errorObj)
def addShapeToGroup(): cdrObj = CDR() layerObj = cdrObj.getLayer('秒秒学装饰') g1 = cdrObj.groupShapeObjs( layerObj, "占位组", ) g2 = cdrObj.groupShapeObjs(layerObj, "子组占位组1", g1) g3 = cdrObj.groupShapeObjs(layerObj, "子组占位组2", g2) g4 = cdrObj.groupShapeObjs(layerObj, "子组占位组3", g3) s1 = layerObj.FindShape("test1") if s1 == None: s1 = cdrObj.drawDecorationTriangle("test1", {"background-color": [255, 0, 0]}, { "bottom": 300, "left": 600 }, 'lefttop') # 增加一个对象到组 cdrObj.addShapeToGroup(g4, s1)
def make(self, mode=CDRSamplerMode.NORMAL): raw_CDR = {k: v.make(mode) for k, v in self.attributes.items()} return CDR(raw_CDR)
from cdr import CDR docPath = 'D:\\AILab\\Data\\CDRs\\test.docx' TEST = 'C:\\Users\\Administrator\\Desktop\\test.cdr' cdr = CDR(TEST) cdr.togglePage(1) layer = cdr.doc.ActiveLayer shape = cdr.doc.ActiveShape cdr.togglePage(1) story = shape.Text.Story paragraphs = story.paragraphs modifyParagraph = [] for paragraph in paragraphs: thetext = paragraph.WideText if '\t' in thetext: # print('thetext',thetext) splits = thetext.split('\t') prefix = splits[0] theord = ord(prefix[0]) if theord > 61000: remain = '' if len(splits) > 0: remain = splits[1] paragraph.Text = remain.strip() + "\r" paragraph.ApplyBulletEffect(prefix, None, paragraph.Size, -1)
def increaseFontSize(): cdrObj = CDR() cdrObj.loadPalette('C:\\Users\\Administrator\\Desktop\\123\\cw.xml')
def __init__(self, n_taps, gain, delta_t, alpha, ui, n_spb, decision_scaler, mod_type=0, bandwidth=100.e9, n_ave=10, n_lock_ave=500, rel_lock_tol=0.01, lock_sustain=500, ideal=True): """ Inputs: Required: - n_taps # of taps in adaptive filter - gain adaptive filter tap weight correction gain - delta_t CDR proportional branch constant (ps) - alpha CDR integral branch constant (normalized to delta_t) - ui nominal unit interval (ps) - n_spb # of samples per unit interval - decision_scaler multiplicative constant applied to the result of the sign function, when making a "1 vs. 0" decision. Sets the target magnitude for the DFE. Optional: - mod_type The modulation type: - 0: NRZ - 1: Duo-binary - 2: PAM-4 - bandwidth The bandwidth, at the summing node (Hz). - n_ave The number of averages to take, before adapting. (Also, the number of CDR adjustments per DFE adaptation.) - n_lock_ave The number of unit interval estimates to consider, when determining locked status. - rel_lock_tol The relative tolerance for determining lock. - lock_sustain Length of the histerysis vector used for lock flagging. - ideal Boolean flag. When true, use an ideal summing node. Raises: Exception: If the requested modulation type is unknown. """ # Design summing node filter. fs = n_spb / ui (b, a) = iirfilter(gNch_taps - 1, bandwidth / (fs / 2), btype='lowpass') self.summing_filter = LfilterSS(b, a) # Initialize class variables. self.tap_weights = [0.0] * n_taps self.tap_values = [0.0] * n_taps self.gain = gain self.ui = ui self.decision_scaler = decision_scaler self.mod_type = mod_type self.cdr = CDR(delta_t, alpha, ui, n_lock_ave, rel_lock_tol, lock_sustain) self.n_ave = n_ave self.corrections = zeros(n_taps) self.ideal = ideal thresholds = [] if (mod_type == 0): # NRZ pass elif (mod_type == 1): # Duo-binary thresholds.append(-decision_scaler / 2.) thresholds.append(decision_scaler / 2.) elif (mod_type == 2): # PAM-4 thresholds.append(-decision_scaler * 2. / 3.) thresholds.append(0.) thresholds.append(decision_scaler * 2. / 3.) else: raise Exception( "ERROR: DFE.__init__(): Unrecognized modulation type requested!" ) self.thresholds = thresholds
def testColor(): cdrObj = CDR() # cdrObj.setColor('测试1',[255,0,0]) cdrObj.createPage(5)
def open(): print(CDR('C:\\Users\\Administrator\\Desktop\\11.cdr'))
def testFont(): # font = TTFont('simsun.ttf') cdrObj = CDR() for k in cdrObj.app.FontList: print(k)
def paletteTest2(): cdrObj = CDR() paletteObj = cdrObj.accessPalette('my') newColor = cdrObj.createColorObj([0, 255, 255], 'unique_key', 'RGB') cdrObj.replacePletteColorByName(paletteObj, newColor)
def paletteTest3(): cdrObj = CDR() print(cdrObj.app.Printers)
def testExportImage(): cdrObj = CDR() cdrObj.exportBitmap( 'C:\\Users\\Administrator\\Desktop\\111\\test\\test.png', 6) pass
def togglePage(): print(CDR().togglePage(2))
def getContent(pageIndex=""): print('返回', CDR().get(pageIndex))
def replacePart(): cdrObj = CDR()