dave-howard / vsdx

vsdx - A python library for processing .vsdx files
BSD 3-Clause "New" or "Revised" License
67 stars 25 forks source link

Getting error while setting page width/height of newly added page or copied page #72

Open beingvishalt opened 4 months ago

beingvishalt commented 4 months ago

Hello, below is my code


from vsdx import VisioFile,Shape,vsdxfile,PagePosition,Page

with VisioFile('test1.vsdx') as vis:
    page1=vis.add_page(name="NewlyAdded")
    page1.width=100 # Getting error for this two lines
    page1.height=200 
    page = vis.pages[0]  

    new_page=vis.copy_page(page,index=PagePosition.AFTER,name="Demo")
    new_page.width=100 # Getting error for this two lines also
    new_page.height=200 

    vis.save_vsdx('copy_of_diagram11.vsdx')  # save to a new file```

    I am getting below error 

 C:\Users\abc\AppData\Local\Programs\Python\Python312\Lib\site-packages\vsdx\pages.py", line 123, in width
    self._pagesheet_xml.find(f'{namespace}Cell[@N="PageWidth"]').attrib['V'] = str(value)
    ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\abc\AppData\Local\Programs\Python\Python312\Lib\site-packages\vsdx\pages.py", line 113, in _pagesheet_xml
    ps = self.vis.masters_xml.find(f'{namespace}Master[@ID="{self.page_id}"]/{namespace}PageSheet')
         ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'find'

@dave-howard  Can you please check and solve this bug.
@dave-howard 
beingvishalt commented 4 months ago

@dave-howard Can you please change page size automatically to fit all diagrams within page, like Visio do