本文介绍了用pdfclown提取矢量图形(线条和点)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用pdfclown从pdf中提取矢量图形(线条和点)。我试图围绕图形样本包裹头部,但我无法弄清楚这个对象模型是如何工作的。请问任何人都可以解释关系吗?

你是对的:直到PDF Clown 0.1系列,高级路径建模没有实现(它将从)。



下一个版本(,下个月到期)将通过新的。这是一个例子:

  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; (GraphicsElement<>元素:ContentModeller.model(page,Path.class))


{
PathElement pathElement =(PathElement)element;
列表< ContentMarker> markers = pathElement.getMarkers();
pathElement.getBox();
GeneralPath getPath = pathElement.getPath();
pathElement.isFilled();
pathElement.isStroked();
}

与此同时,您可以提取矢量图形的低级表示通过迭代内容流为在ContentScanningSample中提供(在可下载发行版中提供),查找与路径相关的操作(,,,,...)。


I want to extract vector graphics (lines and points) out of a pdf with pdfclown. 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).

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. 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, ...).

这篇关于用pdfclown提取矢量图形(线条和点)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 20:59