我想用 pdfclown 从 pdf 中提取矢量图形(线和点)。我试图将我的头脑围绕在图形样本上,但我无法弄清楚对象模型是如何工作的。请问谁能解释一下关系?
问问题
393 次
1 回答
0
你是对的:直到 PDF Clown 0.1 系列,高级路径建模还没有实现(它应该是从ContentScanner.GraphicsWrapper派生的)。
下一个版本(0.2 系列,下个月到期)将通过新的ContentModeller支持所有图形内容的高级表示,包括路径对象(PathElement) 。这是一个例子:
import org.pdfclown.documents.contents.elements.ContentModeller;
import org.pdfclown.documents.contents.elements.GraphicsElement;
import org.pdfclown.documents.contents.elements.PathElement;
import org.pdfclown.documents.contents.objects.Path;
import java.awt.geom.GeneralPath;
for(GraphicsElement<?> element : ContentModeller.model(page, Path.class))
{
PathElement pathElement = (PathElement)element;
List<ContentMarker> markers = pathElement.getMarkers();
pathElement.getBox();
GeneralPath getPath = pathElement.getPath();
pathElement.isFilled();
pathElement.isStroked();
}
同时,您可以按照 ContentScanningSample(可在可下载的发行版中获得)中的建议,通过ContentScanner提取迭代内容流的矢量图形的低级表示,查找与路径相关的操作( BeginSubpath、DrawLine、DrawRectangle、DrawCurve、 . ..)。
于 2015-06-04T10:14:59.443 回答