⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainunit.cpp

📁 生成PDF文档的控件
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "MainUnit.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "VPDFDoc"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	VPDF->BeginDoc( true );                // Create PDF file with outlines
	TVPDFDocOutlineObject * OutlineRoot = VPDF->OutlineRoot;      // Get Outlines Root
	VPDF->CurrentPage->PrintText( 0, 5, 0, "  Page 1 top");           // Mark first page top
	VPDF->CurrentPage->PrintText( 0, 830, 0, "  Page 1 bottom");      // Mark first page bottom
	for ( int I = 2; I <= 100; I++ )
	{
		TVPDFDocOutlineObject * CurrnetOutline = OutlineRoot->AddChild( "Page " + IntToStr(I - 1) , 0, 0);  // Add Outline block linked to 0,0 in current page
		CurrnetOutline->AddChild( "Top ", 0, 0 );                //  Add Outline linked to 0,0 in current page
		CurrnetOutline->AddChild( "Bottom ", 0, 800 );     //  Add Outline linked to 0,800 in current page
		VPDF->AddPage();                                                     // ADD Next Page
		VPDF->CurrentPage->PrintText(0, 5,  0,"  Page " + IntToStr(I) + " top");      // Mark Next page top
		VPDF->CurrentPage->PrintText(0, 830,  0,"  Page " + IntToStr(I) + " bottom"); // Mark Next page bottom
	}
	TVPDFDocOutlineObject * CurrnetOutline = OutlineRoot->AddChild( "Page 100 ", 0, 0 );             // ADD last  Page
	CurrnetOutline->AddChild( "Top " , 0, 0);                      //  Add Outline linked to 0,0 in last page
	CurrnetOutline->AddChild( "Bottom ", 0, 830 );           //  Add Outline linked to 0,830 in last page
	VPDF->EndDoc();                                            // Close PDF file
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -