【发布时间】:2015-06-03 17:00:26
【问题描述】:
我想用 pdfclown 从 pdf 中提取矢量图形(线和点)。我试图将我的头脑围绕在图形样本上,但我无法弄清楚对象模型是如何工作的。请问谁能解释一下关系?
【问题讨论】:
-
我投票决定将此问题作为离题结束,因为它没有询问有关现有代码的特定问题。它只是要求人们解释一个 3rd 方库。
我想用 pdfclown 从 pdf 中提取矢量图形(线和点)。我试图将我的头脑围绕在图形样本上,但我无法弄清楚对象模型是如何工作的。请问谁能解释一下关系?
【问题讨论】:
你是对的:直到 PDF Clown 0.1 系列,高级路径建模还没有实现(它应该是从 ContentScanner.GraphicsWrapper 派生的)。
下一个版本(0.2 series,下个月到期)将支持所有图形内容的高级表示,包括路径对象(PathElement),通过新ContentModeller。这是一个例子:
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, ...)。
【讨论】: