0

I want to capture vector image like this. Vector image There are so many operators "m" and "l" to draw this vector image. GeneralPath object will load these "m" "l" oprs in pdfbox. I wonder if there is some method that can tell me that this is a vector. This file content stream: 91.92 141.48 m 91.92 272.76 l S

88.68 141.48 m 91.92 141.48 l 88.68 160.2 m 91.92 160.2 l 88.68 178.92 m 91.92 178.92 l 88.68 197.76 m 91.92 197.76 l 88.68 216.48 m 91.92 216.48 l 88.68 235.32 m 91.92 235.32 l 88.68 254.04 m 91.92 254.04 l 88.68 272.76 m 91.92 272.76 l S

91.92 197.76 m 388.8 197.76 l S

Dagu
  • 27
  • 7
  • *"I wonder if there is some method that can tell me that this is a vector."* - I don't understand what you are asking. Something with move-tos and line-tos *is* a vector path. – mkl Oct 12 '18 at 05:33
  • I'm so happy that you can reply to my question. Thanks very much! I'm new to PDFBOX, your so many answers help me a lot. My problem is extracting these verctor path to one image. how can i do this? These verctor paths looks like a image, but they are not. – Dagu Oct 12 '18 at 06:25
  • See here: https://stackoverflow.com/questions/38931422/pdfbox-2-0-2-calling-of-pagedrawer-processpage-method-caught-exceptions – Tilman Hausherr Oct 12 '18 at 06:40
  • You could create an empty image of the size of the path shape bounding box and then draw the path there, but the problem would be that for some PDFs, that "vector image" would contain all sort of stuff, e.g. the line found a header or a footer. – Tilman Hausherr Oct 12 '18 at 06:44
  • @TilmanHausherr Thanks very much,I will try. But "the size of the path shape bounding box " may be hard to get. – Dagu Oct 12 '18 at 06:50
  • @Dagu there's a method like `GeneralPath.getBounds2D()` or similar. – Tilman Hausherr Oct 12 '18 at 06:53
  • *"extracting these verctor path to one image"* - what kind of image do you have in mind? Some bitmap or another vector format? Which format exactly? – mkl Oct 12 '18 at 07:59
  • @mkl "what kind of image do you have in mind?" like this [image] [1] [1]: https://i.stack.imgur.com/F23qZ.png – Dagu Oct 12 '18 at 14:37
  • By *"what kind of image do you have in mind"* I meant what I wrote thereafter, i.e. in which format do you want to capture the figure, in particular in some other vector format or as a bitmap. Your referencing that png makes me assume you want to capture it as a bitmap image, probably as a PNG file. – mkl Oct 12 '18 at 15:58
  • @mkl Sorry for replying so late. I want to capture it as a bitmap image, PNG or JPG file. It's easy to extract area region of PDF to a bitmap image by PDFBOX, if i know the coordinates of the area region. The problem may be how to identify the area. – Dagu Oct 15 '18 at 03:12
  • If there is only one such vector image on the page and path related operations are not used for anything else, you can easily determine the bounding box. Otherwise, though, this really is a problem. – mkl Nov 07 '18 at 12:26
  • @mkl there are lots of vector images on the page and path related operations are used for drawing lines, fill regions and so on. if you think this really is a problem. i will quit . Thanks. – Dagu Nov 12 '18 at 02:11
  • I'm afraid I cannot help without the pdf in question. There *might* be hints inside its content streams one can use to differentiate between different figures. – mkl Nov 12 '18 at 07:14

0 Answers0