pdfbox 1.8.2 c#ラッパーを使用して矩形の境界にクラウドを描く機能を実装したいと思います。このlinkで述べられているコードを使用して、 。しかし問題は、私は単一の半円だけを描くことができるということです。私が複数の隣接する半円を描こうとすると、うまくいきません。以下は私が使用しているコードです。PDPageContentStreamを使用して複数の半円を描くことはできません
(createSmallArc()Hans Muller、license: Creative Commons Attribution 3.0によるもので行われた変更:実装するJavaにコードされた元のアルゴリズムAleksas Riškusによるものである)
public void addCloud(PDRectangle rect,PDDocument doc)
{
PDGamma yellow = new PDGamma();
yellow.setR(255);
yellow.setG(255);
yellow.setB(0);
PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get(pageNum);
float width = 215;
float height = 156;
int noXSemiCircles = 21;
int noYSemiCircles = 15;
float leftX = 203;
float bottomY = 424;
int index = 0;
PDPageContentStream cs = new PDPageContentStream(doc, page,true,false);
Matrix mt = Matrix.getTranslatingInstance(leftX + (index * 10), bottomY);
AffineTransform at = mt.createAffineTransform();
cs.concatenate2CTM(at);
cs.setStrokingColor(255, 0, 0);
while (index<noXSemiCircles)
{
cs.moveTo(leftX + (index * 10), bottomY);
DrawSlice(cs, 5, 180,270, true);
DrawSlice(cs, 5, 270, 360, false);
index++;
}
cs.stroke();
cs.close();
doc.save(System.IO.Path.Combine(FilePath));
doc.close();
}
private void DrawSlice(PDPageContentStream cs, float rad, float startDeg, float endDeg,bool move)
{
try
{
List<float> smallArc = CreateSmallArc(rad, ConvertDegreesToRadians(startDeg), ConvertDegreesToRadians(endDeg));
if (move)
{
cs.moveTo(smallArc[0], smallArc[1]);
}
cs.addBezier312(smallArc[2], smallArc[3], smallArc[4], smallArc[5], smallArc[6], smallArc[7]);
}
catch (Exception ex)
{
}
}
実際の数字で、すなわち、あなたの四角形を作成するコードを追加して編集してください。 –
@Tilmanコードに値を追加しました。してください。見てください。単一の半円だけが描画されています。 –