Menu

#1 Fit an image to the page width

open
nobody
None
5
2005-07-27
2005-07-27
No

Nice tool, thanks for your efforts! I had some rather
big images that I wanted to scale down to the page
width, so I created a 'fit_width' keyword to the
Image() class that modifies the scale parameters so
that the image fits the width specified.

Discussion

  • Rob McMullen

    Rob McMullen - 2005-07-27

    Patch for Elements.py

     
  • Rob McMullen

    Rob McMullen - 2005-07-27

    Logged In: YES
    user_id=13885

    Usage example is below. I had to specify the width in the
    Image() constructor because there's no other way of knowing
    what the width of the viewable page is, since the Image is
    not created as a child of the Section.

    doc = Document()
    section = Section(paper=StandardPaper.LETTER)
    doc.Sections.append( section )

    section.append( 'PNG Graphic' )
    image = Image( 'test-2.png', fit_width=section.Width )
    section.append( Paragraph( image ) )

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.