简体   繁体   English

用pdfclown提取矢量图形(线和点)

[英]Extracting vector graphics (lines and points) with pdfclown

I want to extract vector graphics (lines and points) out of a pdf with pdfclown. 我想用pdfclown从pdf中提取矢量图形(线和点)。 I have tried to wrap my head around the graphics sample but i cannot figure out how the object model works for this. 我试图把头放在图形样本上,但是我无法弄清楚对象模型是如何工作的。 Please can anyone explain the relationships? 任何人都可以解释这种关系吗?

You are right: till PDF Clown 0.1 series, high-level path modelling was not implemented (it would have been derived from ContentScanner.GraphicsWrapper ). 您是对的:在PDF Clown 0.1系列之前,尚未实现高级路径建模(它应从ContentScanner.GraphicsWrapper派生)。

Next release ( 0.2 series , due next month) will support the high-level representation of all the graphics contents, including path objects (PathElement), through the new ContentModeller . 下一版本 (将于下个月发布的 0.2系列通过新的ContentModeller 支持所有图形内容的高级表示,包括路径对象 (PathElement)。 Here is an example: 这是一个例子:

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();
}

In the meantime, you can extract the low-level representation of the vector graphics iterating the content stream through ContentScanner as suggested in ContentScanningSample (available in the downloadable distribution), looking for path-related operations ( BeginSubpath , DrawLine , DrawRectangle , DrawCurve , ...). 同时,您可以按照ContentScanningSample(可在下载的发行版中提供)中的建议,通过ContentScanner提取对内容流进行迭代的矢量图形的低级表示,查找与路径相关的操作( BeginSubpathDrawLineDrawRectangleDrawCurve ,)。 ..)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM