adjust object size to page width

hi there
how can an object during/after import be adjusted to the actual document width and/or height easily WITHOUT:

- entering the dimensions manually in the scaling options toolbar
- using the mouse scaling option (click on the object and use the rectangles in the corners/side of the object)

i am looking for an option like "adjust object to document width/height", maybe even with an option "keep dimensions" similar to the "align/adjust" options of an object.

any hints regarding this question?

thanks

puregin

Parents
No Data
Reply
  • puregin said:
    how can an object during/after import be adjusted to the actual document width and/or height easily WITHOUT:

    - entering the dimensions manually in the scaling options toolbar
    - using the mouse scaling option (click on the object and use the rectangles in the corners/side of the object)

    i am looking for an option like "adjust object to document width/height", maybe even with an option "keep dimensions" similar to the "align/adjust" options of an object.

    Are you familiar with using VBA macros? I don't have X6, but the macros shown below work for me in X7.

    This one stretches the object non-proportionally to fit the document size, then centers it to the document.

    Sub resize_object_to_document_not_proportional()
    Dim lay As Layer

        Set lay = ActiveLayer

        If Not lay.SizeWidth = ActiveDocument.SizeWidth Then
            lay.SizeWidth = ActiveDocument.SizeWidth
        End If
        
        If Not lay.SizeHeight = ActiveDocument.SizeHeight Then
            lay.SizeHeight = ActiveDocument.SizeHeight
        End If
        
        lay.SetPosition (ActiveDocument.SizeWidth - lay.SizeWidth) / 2, (ActiveDocument.SizeHeight - lay.SizeHeight) / 2

    End Sub

     

    This one stretches the object proportionally to fit the document size, then centers it to the document.

    Sub resize_object_to_document_proportional()
    Dim lay As Layer
    Dim dblsScaleFactor As Double
    Dim lngWidthNew As Long
    Dim lngHeightNew As Long
       
        Set lay = ActiveLayer
        
        If lay.SizeWidth / lay.SizeHeight < ActiveDocument.SizeWidth / ActiveDocument.SizeHeight Then
            dblsScaleFactor = ActiveDocument.SizeHeight / lay.SizeHeight
        Else
            dblsScaleFactor = ActiveDocument.SizeWidth / lay.SizeWidth
        End If

        lngWidthNew = lay.SizeWidth * dblsScaleFactor
        If Not lay.SizeWidth = lngWidthNew Then
            lay.SizeWidth = lngWidthNew
        End If
        
        lngHeightNew = lay.SizeHeight * dblsScaleFactor
        If Not lay.SizeHeight = lngHeightNew Then
            lay.SizeHeight = lngHeightNew
        End If
        
        lay.SetPosition (ActiveDocument.SizeWidth - lay.SizeWidth) / 2, (ActiveDocument.SizeHeight - lay.SizeHeight) / 2

    End Sub

Children
No Data