/*
	Antenna House PDF Tool API V7.0
	C++ Interface sample program

	概要：スタンプ注釈の作成

	Copyright 2013-2021 Antenna House, Inc.
*/

#include < PdfTk.h >
#include < math.h >
#include < stdio.h >

using namespace PdfTk;

void addPreDefinedStampAnnot(PtlAnnots& annots);
void addPreDefinedStampAnnot2(PtlAnnots& annots);
void addCustomStampAnnotFromPdf(PtlAnnots& annots, const char* pathPdf);
void addCustomStampAnnotFromImage(PtlAnnots& annots, const char* pathImage);
void addCustomStampAnnotFromDrawContent(PtlAnnots& annots);
void drawDateStamp(PtlContent& content, float sizeStamp, const char* szDate, const char* szName);

int main(int argc, char* argv[])
{
	if (argc < 4) {
		printf("usage: AppendAnnotStamp.exe in-pdf-file out-pdf-file スタンプ種類 [in-xxx-file]\n\n");
		printf("スタンプ種類\n0 : 標準  1 : 標準2  2 : カスタム(PDF)  3 : カスタム(Image)  4 : カスタム(日付印)\n");
		return 1;
	}

	try
	{
		PtlParamInput input(argv[1]);
		PtlParamOutput output(argv[2]);

		const char* stampKind = argv[3];
		switch (stampKind[0]) {
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
			break;
		default:
			printf("usage: AppendAnnotStamp.exe in-pdf-file out-pdf-file スタンプ種類 [in-xxx-file]\n\n");
			printf("スタンプ種類\n0 : 標準  1 : 標準2  2 : カスタム(PDF)  3 : カスタム(Image)  4 : カスタム(日付印)\n");
			return 1;
		}

		PtlPDFDocument doc;

		// PDFファイルをロードします。
		doc.load(input);

		// ページコンテナの取得
		PtlPages& pages = doc.getPages();

		// ページコンテナが空かどうか
		if (pages.isEmpty()){
			printf("ページコンテナが空\n");
			return 1;
		}

		// １ページ目の取得
		PtlPage page = pages.get(0);
		
		// 注釈コンテナの取得
		PtlAnnots& annots = page.getAnnots();

		switch (stampKind[0]) {
		case '0':
			// 標準
			addPreDefinedStampAnnot(annots);
			break;
		case '1':
			// 標準2
			addPreDefinedStampAnnot2(annots);
			break;
		case '2':
			// 読み込んだPDFを外観とするスタンプ
			if (argc < 5) {
				printf("usage: java AppendAnnotStamp in-pdf-file out-pdf-file スタンプ種類 in-pdf-file");
				return 1;
			}
			addCustomStampAnnotFromPdf(annots, argv[4]);
			break;
		case '3':
			// 読み込んだ画像を外観とするスタンプ
			if (argc < 5) {
				printf("usage: java AppendAnnotStamp in-pdf-file out-pdf-file スタンプ種類 in-image-file");
				return 1;
			}
			addCustomStampAnnotFromImage(annots, argv[4]);
			break;
		case '4':
			// 日付印を外観として描画
			addCustomStampAnnotFromDrawContent(annots);
			break;
		}

		// ファイルに保存します。
		doc.save(output);

		printf("完了!\n");
	}
	catch (const PtlException &e)
	{
		fprintf(stderr, "Error code : %d\n %s\n", e.getErrorCode(), e.getErrorMessage().c_str());
		return 1;
	}
	return 0;
}

void addPreDefinedStampAnnot(PtlAnnots& annots)
{
	PtlAnnotStamp stampAnnot1;
	stampAnnot1.setIconType(PtlAnnotStamp::ICON_APPROVED);
	PtlRect rectSize1 = stampAnnot1.getRect();
	stampAnnot1.setRect(PtlRect(10.0f, 270.0f, 10.0f+rectSize1.getRight(), 270.0f+rectSize1.getTop()));
	stampAnnot1.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot1);

	PtlAnnotStamp stampAnnot2;
	stampAnnot2.setIconType(PtlAnnotStamp::ICON_AS_IS);
	PtlRect rectSize2 = stampAnnot2.getRect();
	stampAnnot2.setRect(PtlRect(10.0f, 250.0f, 10.0f+rectSize2.getRight(), 250.0f+rectSize2.getTop()));
	stampAnnot2.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot2);

	PtlAnnotStamp stampAnnot3;
	stampAnnot3.setIconType(PtlAnnotStamp::ICON_CONFIDENTIAL);
	PtlRect rectSize3 = stampAnnot3.getRect();
	stampAnnot3.setRect(PtlRect(10.0f, 230.0f, 10.0f+rectSize3.getRight(), 230.0f+rectSize3.getTop()));
	stampAnnot3.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot3);

	PtlAnnotStamp stampAnnot4;
	stampAnnot4.setIconType(PtlAnnotStamp::ICON_DEPARTMENTAL);
	PtlRect rectSize4 = stampAnnot4.getRect();
	stampAnnot4.setRect(PtlRect(10.0f, 210.0f, 10.0f+rectSize4.getRight(), 210.0f+rectSize4.getTop()));
	stampAnnot4.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot4);

	PtlAnnotStamp stampAnnot5;
	stampAnnot5.setIconType(PtlAnnotStamp::ICON_DRAFT);
	PtlRect rectSize5 = stampAnnot5.getRect();
	stampAnnot5.setRect(PtlRect(10.0f, 190.0f, 10.0f+rectSize5.getRight(), 190.0f+rectSize5.getTop()));
	stampAnnot5.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot5);

	PtlAnnotStamp stampAnnot6;
	stampAnnot6.setIconType(PtlAnnotStamp::ICON_EXPERIMENTAL);
	PtlRect rectSize6 = stampAnnot6.getRect();
	stampAnnot6.setRect(PtlRect(10.0f, 170.0f, 10.0f+rectSize6.getRight(), 170.0f+rectSize6.getTop()));
	stampAnnot6.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot6);

	PtlAnnotStamp stampAnnot7;
	stampAnnot7.setIconType(PtlAnnotStamp::ICON_EXPIRED);
	PtlRect rectSize7 = stampAnnot7.getRect();
	stampAnnot7.setRect(PtlRect(10.0f, 150.0f, 10.0f+rectSize7.getRight(), 150.0f+rectSize7.getTop()));
	stampAnnot7.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot7);

	PtlAnnotStamp stampAnnot8;
	stampAnnot8.setIconType(PtlAnnotStamp::ICON_FINAL);
	PtlRect rectSize8 = stampAnnot8.getRect();
	stampAnnot8.setRect(PtlRect(10.0f, 130.0f, 10.0f+rectSize8.getRight(), 130.0f+rectSize8.getTop()));
	stampAnnot8.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot8);

	PtlAnnotStamp stampAnnot9;
	stampAnnot9.setIconType(PtlAnnotStamp::ICON_FOR_COMMENT);
	PtlRect rectSize9 = stampAnnot9.getRect();
	stampAnnot9.setRect(PtlRect(10.0f, 110.0f, 10.0f+rectSize9.getRight(), 110.0f+rectSize9.getTop()));
	stampAnnot9.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot9);

	PtlAnnotStamp stampAnnot10;
	stampAnnot10.setIconType(PtlAnnotStamp::ICON_FOR_PUBLIC_RELEASE);
	PtlRect rectSize10 = stampAnnot10.getRect();
	stampAnnot10.setRect(PtlRect(10.0f, 90.0f, 10.0f+rectSize10.getRight(), 90.0f+rectSize10.getTop()));
	stampAnnot10.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot10);

	PtlAnnotStamp stampAnnot11;
	stampAnnot11.setIconType(PtlAnnotStamp::ICON_NOT_APPROVED);
	PtlRect rectSize11 = stampAnnot11.getRect();
	stampAnnot11.setRect(PtlRect(10.0f, 70.0f, 10.0f+rectSize11.getRight(), 70.0f+rectSize11.getTop()));
	stampAnnot11.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot11);

	PtlAnnotStamp stampAnnot12;
	stampAnnot12.setIconType(PtlAnnotStamp::ICON_NOT_FOR_PUBLIC_RELEASE);
	PtlRect rectSize12 = stampAnnot12.getRect();
	stampAnnot12.setRect(PtlRect(10.0f, 50.0f, 10.0f+rectSize12.getRight(), 50.0f+rectSize12.getTop()));
	stampAnnot12.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot12);

	PtlAnnotStamp stampAnnot13;
	stampAnnot13.setIconType(PtlAnnotStamp::ICON_SOLD);
	PtlRect rectSize13 = stampAnnot13.getRect();
	stampAnnot13.setRect(PtlRect(10.0f, 30.0f, 10.0f+rectSize13.getRight(), 30.0f+rectSize13.getTop()));
	stampAnnot13.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot13);

	PtlAnnotStamp stampAnnot14;
	stampAnnot14.setIconType(PtlAnnotStamp::ICON_TOP_SECRET);
	PtlRect rectSize14 = stampAnnot14.getRect();
	stampAnnot14.setRect(PtlRect(10.0f, 10.0f, 10.0f+rectSize14.getRight(), 10.0f+rectSize14.getTop()));
	stampAnnot14.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot14);
}

void addPreDefinedStampAnnot2(PtlAnnots& annots)
{
	PtlAnnotStamp stampAnnot1;
	stampAnnot1.setIconType(PtlAnnotStamp::ICON_SB_APPROVED);
	PtlRect rectSize1 = stampAnnot1.getRect();
	stampAnnot1.setRect(PtlRect(10.0f, 270.0f, 10.0f+rectSize1.getRight(), 270.0f+rectSize1.getTop()));
	stampAnnot1.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot1);

	PtlAnnotStamp stampAnnot2;
	stampAnnot2.setIconType(PtlAnnotStamp::ICON_SB_COMPLETED);
	PtlRect rectSize2 = stampAnnot2.getRect();
	stampAnnot2.setRect(PtlRect(10.0f, 250.0f, 10.0f+rectSize2.getRight(), 250.0f+rectSize2.getTop()));
	stampAnnot2.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot2);

	PtlAnnotStamp stampAnnot3;
	stampAnnot3.setIconType(PtlAnnotStamp::ICON_SB_CONFIDENTIAL);
	PtlRect rectSize3 = stampAnnot3.getRect();
	stampAnnot3.setRect(PtlRect(10.0f, 230.0f, 10.0f+rectSize3.getRight(), 230.0f+rectSize3.getTop()));
	stampAnnot3.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot3);

	PtlAnnotStamp stampAnnot4;
	stampAnnot4.setIconType(PtlAnnotStamp::ICON_SB_DRAFT);
	PtlRect rectSize4 = stampAnnot4.getRect();
	stampAnnot4.setRect(PtlRect(10.0f, 210.0f, 10.0f+rectSize4.getRight(), 210.0f+rectSize4.getTop()));
	stampAnnot4.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot4);

	PtlAnnotStamp stampAnnot5;
	stampAnnot5.setIconType(PtlAnnotStamp::ICON_SB_FINAL);
	PtlRect rectSize5 = stampAnnot5.getRect();
	stampAnnot5.setRect(PtlRect(10.0f, 190.0f, 10.0f+rectSize5.getRight(), 190.0f+rectSize5.getTop()));
	stampAnnot5.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot5);

	PtlAnnotStamp stampAnnot6;
	stampAnnot6.setIconType(PtlAnnotStamp::ICON_SB_FOR_COMMENT);
	PtlRect rectSize6 = stampAnnot6.getRect();
	stampAnnot6.setRect(PtlRect(10.0f, 170.0f, 10.0f+rectSize6.getRight(), 170.0f+rectSize6.getTop()));
	stampAnnot6.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot6);

	PtlAnnotStamp stampAnnot7;
	stampAnnot7.setIconType(PtlAnnotStamp::ICON_SB_FOR_PUBLIC_RELEASE);
	PtlRect rectSize7 = stampAnnot7.getRect();
	stampAnnot7.setRect(PtlRect(10.0f, 150.0f, 10.0f+rectSize7.getRight(), 150.0f+rectSize7.getTop()));
	stampAnnot7.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot7);

	PtlAnnotStamp stampAnnot8;
	stampAnnot8.setIconType(PtlAnnotStamp::ICON_SB_INFORMATIONONLY);
	PtlRect rectSize8 = stampAnnot8.getRect();
	stampAnnot8.setRect(PtlRect(10.0f, 130.0f, 10.0f+rectSize8.getRight(), 130.0f+rectSize8.getTop()));
	stampAnnot8.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot8);

	PtlAnnotStamp stampAnnot9;
	stampAnnot9.setIconType(PtlAnnotStamp::ICON_SB_NOT_APPROVED);
	PtlRect rectSize9 = stampAnnot9.getRect();
	stampAnnot9.setRect(PtlRect(10.0f, 110.0f, 10.0f+rectSize9.getRight(), 110.0f+rectSize9.getTop()));
	stampAnnot9.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot9);

	PtlAnnotStamp stampAnnot10;
	stampAnnot10.setIconType(PtlAnnotStamp::ICON_SB_NOT_FOR_PUBLIC_RELEASE);
	PtlRect rectSize10 = stampAnnot10.getRect();
	stampAnnot10.setRect(PtlRect(10.0f, 90.0f, 10.0f+rectSize10.getRight(), 90.0f+rectSize10.getTop()));
	stampAnnot10.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot10);

	PtlAnnotStamp stampAnnot11;
	stampAnnot11.setIconType(PtlAnnotStamp::ICON_SB_PRELIMINARYRESULTS);
	PtlRect rectSize11 = stampAnnot11.getRect();
	stampAnnot11.setRect(PtlRect(10.0f, 70.0f, 10.0f+rectSize11.getRight(), 70.0f+rectSize11.getTop()));
	stampAnnot11.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot11);

	PtlAnnotStamp stampAnnot12;
	stampAnnot12.setIconType(PtlAnnotStamp::ICON_SB_VOID);
	PtlRect rectSize12 = stampAnnot12.getRect();
	stampAnnot12.setRect(PtlRect(10.0f, 50.0f, 10.0f+rectSize12.getRight(), 50.0f+rectSize12.getTop()));
	stampAnnot12.setAnnotFlags(PtlAnnot::FLAG_PRINT);
	annots.append(stampAnnot12);
}

void addCustomStampAnnotFromPdf(PtlAnnots& annots, const char* pathPdf)
{
	PtlAnnotStamp stampAnnot;
	
	PtlPDFDocument doc_custom;
	// PDFファイル
	PtlParamInput inputCustom(pathPdf);
	// スタンプにするPDFファイルをロードします。
	doc_custom.load(inputCustom);

    PtlPages& pagesCustomStamp = doc_custom.getPages();
	// ページコンテナが空かどうか
    if (pagesCustomStamp.isEmpty())
    {
		printf("ページコンテナが空\n");
        return;
    }

	// 追加された画像ページを取得する
	PtlPage pageCustomStamp = pagesCustomStamp.get(0);
	// 画像ページを注釈に追加する
	stampAnnot.setPage(pageCustomStamp);

	PtlSize size = pageCustomStamp.getSize();

	stampAnnot.setRect(PtlRect(10.0f, 100.0f, 10.0f+size.getWidth(), 100.0f+size.getHeight()));
	stampAnnot.setIconType(PtlAnnotStamp::ICON_CUSTOM);
	stampAnnot.setAnnotFlags(PtlAnnot::FLAG_PRINT);

	stampAnnot.setIconName("MyIcon");

	annots.append(stampAnnot);
}

void addCustomStampAnnotFromImage(PtlAnnots& annots, const char* pathImage)
{
	PtlAnnotStamp stampAnnot;

	// 画像描画パラメータ
	PtlParamDrawImage paramDrawImage;
	// 画像ファイル
	PtlParamInput inputCustom(pathImage);
	// 画像描画パラメータに画像ファイルを設定
	paramDrawImage.setImageStream(inputCustom);
	
	// 画像ページパラメータ
	PtlParamImagePage paramImagePage;
	// 画像ページパラメータに画像描画パラメータを設定
	paramImagePage.setImage(paramDrawImage);
	// 画像ページのサイズを画像サイズにあわせる
	paramImagePage.setPaperType(PtlParamImagePage::PAPER_IMAGE_SIZE);

	// 画像ページパラメータから作成したページ
	PtlPage pageCustomStamp(paramImagePage);

	// 画像ページを注釈に追加する
	stampAnnot.setPage(pageCustomStamp);

	PtlSize size = pageCustomStamp.getSize();

	stampAnnot.setRect(PtlRect(10.0f, 100.0f, 10.0f+size.getWidth(), 100.0f+size.getHeight()));
	stampAnnot.setIconType(PtlAnnotStamp::ICON_CUSTOM);
	stampAnnot.setAnnotFlags(PtlAnnot::FLAG_PRINT);

	stampAnnot.setIconName("MyIcon");

	annots.append(stampAnnot);
}

void addCustomStampAnnotFromDrawContent(PtlAnnots& annots)
{
	// スタンプサイズ
	float sizeStamp = 30.0f;

	PtlAnnotStamp stampAnnot;

	stampAnnot.setRect(PtlRect(10.0f, 100.0f, 10.0f + sizeStamp, 100.0f + sizeStamp));
	stampAnnot.setIconType(PtlAnnotStamp::ICON_CUSTOM);
	stampAnnot.setAnnotFlags(PtlAnnot::FLAG_PRINT);

	// 日付印を描画する仮のページ
	PtlPage pageCustomStamp;
	pageCustomStamp.setMediaBox(PtlRect(0, 0, sizeStamp, sizeStamp));

	// 日付印を描画するコンテント
	PtlContent& content = pageCustomStamp.getContent();

	// コンテントに日付印を描画
	//drawDateStamp(content, sizeStamp, "2014/09/8", "鈴木");
	drawDateStamp(content, sizeStamp, "2014/09/8", "Suzuki");

	// 画像ページを注釈に追加する
	stampAnnot.setPage(pageCustomStamp);

	stampAnnot.setIconName("MyIcon");

	annots.append(stampAnnot);
}

void drawDateStamp(PtlContent& content, float sizeStamp, const char* szDate, const char* szName)
{
	// スタンプに外接する矩形
	PtlRect rectStamp(0, 0, sizeStamp, sizeStamp);

	// スタンプの色
	PtlColorDeviceRGB color = PtlColorDeviceRGB(1.0f, 0.0f, 0.0f);

	// スタンプの円/線を描画するパラメーター
	PtlParamDrawShape paramDrawShape;
	paramDrawShape.setLineStyle(PtlParamDrawShape::LINE_STYLE_SOLID);
	paramDrawShape.setLineWidth(PtlParamDrawShape::LINE_WIDTH_THIN);
	paramDrawShape.setLineColor(color);
	paramDrawShape.setFillColor(PtlColorNone());

	// スタンプの円を描画
	content.drawCircle(rectStamp, paramDrawShape);

	#define PI 3.141592
	// 円の中心から15度で線と円が交わるとする
	double rad = 15.0f * PI / 180.0;
	// 円の半径
	float r = sizeStamp / 2;
	// 円の中心から交点へのx方向の長さ
	float xx = r * (float)cos(rad);
	// 円の中心から交点へのy方向の長さ
	float yy = r * (float)sin(rad);
	// 上線左端のx座標
	float from_x = r - xx;
	// 上線左端のy座標
	float to_x = r + xx;
	// 下線左端のx座標
	float upper_y = r + yy;
	// 下線左端のy座標
	float lower_y = r - yy;

	// 円の中に上線を描画
	content.drawLine(PtlPoint(from_x,upper_y), PtlPoint(to_x,upper_y), paramDrawShape);
	// 円の中に下線を描画
	content.drawLine(PtlPoint(from_x,lower_y), PtlPoint(to_x,lower_y), paramDrawShape);

	// 日付のフォント
	float fontSizeDate = sizeStamp / 2.15f;	// yyyy/mm/dd を想定
	//PtlParamFont fontDate(PtlParamString("ＭＳ ゴシック"), fontSizeDate, PtlParamFont::WEIGHT_NORMAL, false, true);
	PtlParamFont fontDate(PtlParamString("Helvetica"), fontSizeDate, PtlParamFont::WEIGHT_NORMAL, false, true);

	// 日付
	PtlParamString textDate(szDate);

	// 日付を描画するパラメーター
	PtlParamWriteString paramWriteStringDate;
	paramWriteStringDate.setFont(fontDate);
	paramWriteStringDate.setTextColor(color);
	paramWriteStringDate.setOutlineColor(color);

	// 日付を描画する矩形
	PtlRect rectDate(from_x, lower_y, to_x, upper_y);

	// 日付を描画
	content.writeString(rectDate, PtlContent::ALIGN_CENTER, textDate, paramWriteStringDate);

	// 名前のフォント
	float fontSizeName = sizeStamp / 1.5f;

	// 下線から名前を描画する矩形までのマージン
	float margin = sizeStamp / 40.0f;

	// 名前を書く矩形の高さ
	float heightNameBase = upper_y-lower_y;
	float heightName = fontSizeName * 25.4f / 72.0f;
	while (heightName > heightNameBase) {
		fontSizeName -= 0.5f;
		heightName = fontSizeName * 25.4f / 72.0f;
	}

	// 名前のフォント
	//PtlParamFont fontName(PtlParamString("ＭＳ 明朝"), fontSizeName, PtlParamFont::WEIGHT_NORMAL, false, true);
	PtlParamFont fontName(PtlParamString("Helvetica"), fontSizeName, PtlParamFont::WEIGHT_NORMAL, false, true);

	// 線の幅
	float widthLine = 0.5f;
	// 線幅を減じた円の半径
	float rr = r - widthLine;
	// 名前の高さのラジアン
	float d = asin((heightName + yy + margin)/rr);
	// 名前をおさめる矩形の幅
	float widthName = rr * (float)cos(d) * 2;

	// 名前
	PtlParamString textName(szName);
	float textWidthName = fontName.getStringWidth(textName);

	// 名前の長さによるフォントサイズの調整
	while (textWidthName > widthName) {
		fontSizeName -= 0.5f;
		fontName.setSize(fontSizeName);
		textWidthName = fontName.getStringWidth(textName);
		heightName = fontSizeName * 25.4f / 72.0f;
		d = asin((heightName + yy + margin)/rr);
		widthName = rr * (float)cos(d) * 2;
	}

	// 名前を描画するパラメーター
	PtlParamWriteString paramWriteStringName;
	paramWriteStringName.setFont(fontName);
	paramWriteStringName.setTextColor(color);
	paramWriteStringName.setOutlineColor(color);

	// 名前を描画する矩形
	PtlRect rectName(from_x, lower_y-heightName-margin, to_x, lower_y-margin);

	// 名前を描画
	content.writeString(rectName, PtlContent::ALIGN_CENTER, textName, paramWriteStringName);
}
