2
$\begingroup$

I can get a Graphics object from a PDF file like

graphic=Import["http://exampledata.wolfram.com/article.pdf",{"PageGraphics",3}];
Head[graphic]

Graphics

Then I crop it to get that table:

result = ImageTake[graphic,{70,300},{90,730}]

enter image description here

But note the head of result is changed into Image, It's not in vector format now

Head[result]

Image

But I hope it keeps be Graphics still, is possible?

$\endgroup$
7
  • $\begingroup$ What gives Head[graphic]? $\endgroup$ Commented Oct 24, 2022 at 12:17
  • $\begingroup$ @UlrichNeumann fixed $\endgroup$
    – yode
    Commented Oct 24, 2022 at 12:20
  • $\begingroup$ Mathematica v12.2 evaluates Head[graphic] (*List*) $\endgroup$ Commented Oct 24, 2022 at 12:29
  • 1
    $\begingroup$ @UlrichNeumann As I know, the PageGraphics is a new feature of 13 $\endgroup$
    – yode
    Commented Oct 24, 2022 at 12:36
  • $\begingroup$ ImageTake takes an Image for the first argument. If a Graphics expression is provided, it will be Rasterize'd first. $\endgroup$
    – ihojnicki
    Commented Oct 24, 2022 at 12:38

1 Answer 1

2
$\begingroup$

This method visually crops the PDF page as a Graphics object, but the PDF page itself is not modified. Suitable if the PDF page is not too bulky.

graphic = Import["http://exampledata.wolfram.com/article.pdf",
   {"PageGraphics", 3}];
idim = ImageDimensions[graphic];
Graphics[{White, Rectangle[{0, 0}, {950, 310}],
  Inset[graphic, {Center, Center}, {Center, 650}, idim]},
 PlotRange -> {{0, 950}, {0, 310}}, ImageSize -> 700]
$\endgroup$
1
  • 1
    $\begingroup$ This does something similar: Graphics[graphic[[1]], PlotRange-> {{70,540},{580,720}}, PlotRangePadding-> 0, ImageMargins->0, ImagePadding-> None] $\endgroup$
    – chuy
    Commented Oct 24, 2022 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.