# How to import vector graph into coordinates system?

Suppose I have smile.pdf; it's a vector graph. I can Import["smile.pdf"] like below:

How to put this vector graph into coordinates system? Then I can easy rotate and move it.

Import the *.pdf file:

smiley = First[Import["xx.pdf"]];

Inspecting the result, we find the following:

Shallow[InputForm[smiley], 7]
InputForm[Graphics[{Thickness[0.001634], Style[{FilledCurve[<<2>>]},
FaceForm[RGBColor[<<4>>]]]}, ImageSize -> {612., 792.},
PlotRange -> {{0., 612.}, {0., 792.}}, AspectRatio -> Automatic]]

Particularly important here is the PlotRange setting, which lets us reckon where the FilledCurve[] representing the shape is centered. One can then do something like this:

Graphics[{Blue, First[Cases[smiley, _FilledCurve, ∞]] /. {x_, y_} :>
Composition[RotationTransform[60 °],
ScalingTransform[{1, 1}/50]][{x, y} - {306, 396}]},
Background -> Yellow, Frame -> True, FrameStyle -> Gray]

• Even I change another pdf,I got same result likeInputForm[Graphics[{Thickness[0.001634], Style[{FilledCurve[<<2>>]},I cannot understand why – kittygirl Mar 7 '18 at 11:53
• That's why I asked for a specific PDF file; the strategy will need to be modified for a different PDF, since it is unreasonable to expect PDFs to have uniformity. – J. M. will be back soon Mar 7 '18 at 11:56
• Actually, I design vector graph in Adobe Illustrator, and import to Mathematica. Which format is best for import?I mean we should have a general method. – kittygirl Mar 7 '18 at 12:04
• "I mean we should have a general method." - unless you can enforce in Illustrator that your vector images be within a preset coordinate range, I don't see a general method being possible. – J. M. will be back soon Mar 7 '18 at 12:08
• "I mean we should have a general method." - unless you can enforce in Illustrator that your vector images be within a preset coordinate range, I don't see a general method being possible. – J. M. will be back soon Mar 7 '18 at 12:09

For your example file, after importing the file, just grab the first element which you need and reconstruct graphics with the geometric transformation you want.

If you check InputForm[test4] like J.M. suggested, you can see why you only need to take the first element.

test4 = First[Import["test4.pdf"]];
Shallow[InputForm[test4], 7]
InputForm[ Graphics[{ Thickness[0.0016339869281045752],  Style[{
FilledCurve[ Skeleton[2]]},  FaceForm[ RGBColor[ Skeleton[4]]]],
Style[{ JoinedCurve[ Skeleton[3]]},  JoinForm[{ Skeleton[2]}]],
Style[{ FilledCurve[ Skeleton[2]]},
Thickness[0.0016339869281045752]]}, ImageSize -> {612., 792.},
PlotRange -> {{0., 612.}, {0., 792.}}, AspectRatio -> Automatic]]
Graphics[Translate[Rotate[test4[[1]], 30 Degree], {-290, -411}],
Frame -> True]

• where did you get -290,-411? – kittygirl Mar 7 '18 at 15:04
• I just manually typed it. – halmir Mar 7 '18 at 16:07