8

Question Overview

I'm using Powerpoint to create my drawings. When using the normal slide size, there is some white area around the graphics. In Visio, one could crop the page to fit the margins of the contained graphics. How is this possible in powerpoint? Meaning, that the boundingbox of the contained objects is the size of the slide.

Long Motivation

Powerpoint got better the last years. Especially when handling figures, it even superseeds Microsoft Visio in some cases. Therefore, Powerpoint got more and more the tool of choice for creating diagrams. Even more complex diagrams with more than 10 shapes are easily possible.

When using the diagrams in a scientific publication, e.g., with LaTeX, the size of the diagrams are typically not following the usual dimensions of a powerpoint slide, but have dimensions fitting to the paper. Typically, the height is different from the typical height of a powerpoint slide.

I do not take a screenshot, because a screenshot is raster graphics. I do a PDF export as the PDF keeps the vector information. See for instance Best way to describe vector vs raster for a discussion, why vector graphics is useful.

I hope, following screenshot makes it clear that a different format is neded. I am very aware that this presentation is a quick sketch without using the complete power of powerpoint. Screenshot of a drawing

The intended workflow is:

  1. Create diagram in PowerPoint
  2. Crop diagram
  3. Save diagram as PDF
  4. Use \includegraphics{diagram.pdf} in LaTeX

Current workflow:

Alternative A: Replace step 2 with following sequence:

  1. Mark all shapes
  2. Cut all shapes
  3. Change slide size
  4. Paste all shapes
  5. If there is some border mismatch, goto 2

Alternative B: insert step 3a:

  1. Open PDF in Acrobat Professional
  2. Use the page cropping tool of Acrobat
  3. Save PDF

I know that PDF Scissors can also be used, but this is still manual work.

Comments

Regarding Alternative A: At each minor change of the diagram, I don't have to adjust the slide borders. If I do a major change, I might have to adjust the borders manually.

Regarding Alternative B: I have to do the cropping each time, I change the figure

There is also Alternative C, where I use the trim feature of the LaTeX graphicx package. However, at each major change of the slide, I have to guess the correct values, which makes this alternative similar to Alternative A.

Related Work

I found How to resize slide dimensions without resizing any objects on the slide? and the answer by JarynPL seems to be promising. Possibly, his macro has to be modified "only". If there is no definitive solution, I'll do it for myself and post it here.

4 Answers 4

1

Based on what you explained:

A.
What you request is not possible in the PowerPoint by simple command somewhere on toolbar because main purpose of the PowerPoint is elsewhere.

B.
It is possible to create macro using VBA programming. Programmatically

  1. Iterate over all shapes and calculate top, left, bottom and right edge of all (= of entire drawing).
  2. Move every shape (set its Left and Top properties) so that center of the entire drawing (of group of shapes) will become the center of the slide. Reason: I can see that size change is made in relation to the center of the slide, so center your stuff before slide resizing.
  3. Set slide size to width and height calculated from values collected in step 1.

Based on your StackOverflow profile, I can see you are a programmer so if you really need this feature, it shouldn't be so difficult for you to put it together and save a lot of time in future on resizing of slides.

Shapes are in collection ActivePresentation.Slides(1).Shapes (use For Each ... Next). You can find a ton of examples – keyword is vba, e.g. vba powerpoint resize slide or vba powerpoint iterate shapes.

VBA code editor is reachable using Alt+F11. In editor, object model can be studied using F2 – object inspector. Every object is well-documented, press help icon in object inspector. Store your macro in the presentation and save your file as type PowerPoint macro-enabled presentation or as PowerPoint macro-enabled template. If you get stuck, first search and then feel free to ask at the StackOverflow. VBA coding is relatively trivial. It has couple of oddities (do not use parenthesis on procedure call, only in function call; element indexes in collections start at 1), but they are quite bearable.

Also see commands in Debug menu to boost up your development. You can modify the live code when your program waits (yellow line) and you can use Set next statement command to move your current execution point forward or back, wherever you want. A great time saver.

When in PowerPoint, you can open the macro list using Alt+F8 or from View menu.

2
  • I refined my motivation again, especially adding a paragraph on vector vs. raster graphics.
    – koppor
    Oct 7, 2015 at 0:44
  • 1
    A couple of possibilities: 1) Select and group the shapes on your slide, right click and choose Save As Picture. Choose EMF or WMF in the Save As dialog box. 2) Create a new presentation with slide size set as required, select and copy the content from your diagram slide, paste it into the new presentation. Oct 16, 2015 at 14:41
1

You can install the python module https://github.com/abarker/pdfCropMargins and execute the following batch script:

REM Remember to install pdfCropMargins
REM 
REM pip install pdfCropMargins --upgrade

if not exist "uncropped" mkdir uncropped
if not exist "copped" mkdir cropped

FOR %%i IN (*.pdf) DO (
        pdf-crop-margins %%i  --verbose --modifyOriginal --usePrefix --stringSeparator "/" --noclobberOriginal
    )

pause

This will crop all files of the folder containing the batch script.

And with the following batch script, you can just drang&drop the exported .pdfonto the .bat file.

REM Remember to install pdfCropMargins
REM 
REM pip install pdfCropMargins --upgrade

if not exist "uncropped" mkdir uncropped
if not exist "copped" mkdir cropped

set arg1=%1
pdf-crop-margins "%arg1%"  --verbose --usePrefix --stringSeparator "/" --threshold 230


pause
0

There is now a right-click menu where you can save every shape as a separate picture.

2
  • 2
    Can you explain how this answers the question? Please do not respond in comments; edit your answer to make it clearer and more complete. Oct 29, 2018 at 9:34
  • ...which does not support saving as pdf. Nov 28, 2023 at 7:26
0

Your texlive suite should have a pdfcrop tool that should crop your exported pdf automatically.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .