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

📄 mainunit.cpp

📁 生成PDF文档的控件
💻 CPP
字号:
//*******************************************************//
//                                                       //
//       This unit is part of the VISPDF VCL library.    //
//       Written by R.Husske - ALL RIGHTS RESERVED.      //
//                                                       //
//       Copyright (C) 2000-2008, www.vispdf.com         //
//                                                       //
//       e-mail: support@vispdf.com                      //
//       http://www.vispdf.com                           //
//                                                       //
//*******************************************************//
//---------------------------------------------------------------------------

#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->AutoLaunch =true;                  // PDF file will be shown automatically
    VPDF->PageLayout =plOneColumn;           // One column viewer mode
    VPDF->BeginDoc( true );                  // Create PDF file with outlines

    TVPDFDocOutlineObject * OutlineRoot = VPDF->OutlineRoot; // Get Outlines Root
    OutlineRoot->AddChild( "Image rotation" , 0, 0); // Add Outline block linked to 0, 0 in current page
    OutlineRoot->AddChild( "Image zoom ", 0, 800 );  // Add Outline block linked to 0, 800 in current page

    VPDF->CurrentPage->SetFont("Arial", TFontStyles() << fsBold << fsUnderline, 24, 0, false); // Set font for header
    VPDF->CurrentPage->PrintText(200, 10, 0, "VisPDF Image Demo");                      // Print text
    int Index = VPDF->AddImageFromFile( "Image.jpg", icJpeg, false, -1 );                 // Add image to the document
    VPDF->CurrentPage->SetFont("Arial", TFontStyles()<< fsUnderline, 18, 0, False);            // Set font for subheader
    VPDF->CurrentPage->PrintText(10, 40, 0, "IMAGE ROTATION");                          // Print text

    int I = 0;
    while (I < 360)
    {
        VPDF->CurrentPage->ShowImage( Index, 300, 130, 130, 100, I ); // Show image and rotate
        I += 30;
    }

    VPDF->CurrentPage->PrintText(10, 400, 0, "IMAGE ZOOM");              // Print text
    VPDF->CurrentPage->SetFont("Times New Roman", TFontStyles(), 14, 0, false); // Set font for text

    VPDF->CurrentPage->ShowImage( Index, 10, 430, 390, 300, 0 );    // Show image with sizes 390 x 300
    VPDF->CurrentPage->PrintText( 180, 730, 0, "390 X 300");        // Print text

    VPDF->CurrentPage->ShowImage( Index, 430, 430, 130, 100, 0 );   // Show image with sizes 130 x 100
    VPDF->CurrentPage->PrintText( 470, 530, 0, "130 X 100");        // Print text

    VPDF->EndDoc();                                            // Close PDF file
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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