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

📄 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 resource "*.dfm"
TMainForm *MainForm;

__fastcall TMainForm::TMainForm(TComponent* Owner)
        : TForm(Owner)
{
}

void __fastcall TMainForm::Button1Click(TObject *Sender)
{
   Single CurrntParaLine;
   int ImageIndex;
   int ParaIndex1;
   int ParaIndex2;

    VPDF->BeginDoc(false);                                          // Create PDF file

    ParaIndex1 = VPDF->CreateParagraph( 20, jtLeft, 60, 60, 30, 30  ); // Create main paragraph
    ParaIndex2 = VPDF->CreateParagraph( 20, jtLeft, 230, 60, 90, 30  ); // Create narrow paragraph
    ImageIndex = VPDF->AddImageFromFile("white_cover.jpg", icJpeg, false, -1);

    VPDF->ParaAutoAddPage = true;   // Paragraph will add pages automatically

    VPDF->BeginParagraph(ParaIndex1);                                        // Open  main paragraph
    VPDF->CurrentPage->SetFont("Arial", TFontStyles() << fsBold, 14, 0, false );   // Set the paragraph font
    VPDF->CurrentParagraph->Justification = jtCenter;                        // Set the paragraph justification
    VPDF->CurrentPage->SetRGBFillColor(clGray);
    VPDF->CurrentParagraph->PrintText("VCL component for Delphi for creating PDF documents."); // Print paragraph text
    VPDF->CurrentPage->SetRGBFillColor(clBlack);
    VPDF->EndParagraph();

    VPDF->CurrentPage->ShowImage(ImageIndex, 57, 80, 150, 185, 0);      // Show box Image

    VPDF->BeginParagraph(ParaIndex2);                                  // Open  narrow paragraph

        VPDF->CurrentPage->SetFont("Arial", TFontStyles(), 14, 0, false );                   // Set the paragraph font
        // Print paragraph text
        VPDF->CurrentParagraph->PrintText("VisPDF Lib is a VCL component for Delphi andC++Builder  for creating PDF documents.  VisPDF does not  use any DLL  or other software to create PDF files. The VisPDF Lib distribution includes the complete help system and many demo programs");
        VPDF->CurrentParagraph->PrintText(": PDF load and edit examples,PDF console application samples,PDF GUI application samples,server PDF application sample etc.");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentPage->SetFont("Arial", TFontStyles() << fsBold << fsItalic, 14, 0, false );       // Set the paragraph font
        VPDF->CurrentParagraph->PrintText("In addition, the full version of VisPDF contains full source code.");  // Print paragraph text
        VPDF->CurrentPage->SetFont("Arial", TFontStyles(), 14, 0, false );                       // Set the paragraph font
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->PrintText("Using VisPDF Lib in your software, you will be able to create PDF reports and PDF books easily.");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->NewLine(); // Line break
        CurrntParaLine = VPDF->CurrentParagraph->CurrentLine;  //Get current print line

    VPDF->EndParagraph();                 // Close the paragraph
    VPDF->BeginParagraph(ParaIndex1);   // Open  main paragraph

        VPDF->CurrentParagraph->CurrentLine = CurrntParaLine;  //Set current print line
        // Print paragraph text
        VPDF->CurrentParagraph->PrintText("Using  VisPDF Lib, it is easy  to add graphic files ( JPG,BMP and others ) into a PDF document, protect it with a password, add acroforms, watermarks, digital signatures, outlines and other.");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->NewLine(); // Line break
        // Print paragraph text
        VPDF->CurrentParagraph->PrintText("VisPDF Lib supports: generating PDF documents with internal and external links, full support unicode characters, editing and creating JavaScript functions, full font embedding, vector and raster graphics, text formatting,");
        VPDF->CurrentParagraph->PrintText("multi-column text, predefined code pages, web links, file links, page links, bookmarks, tiff to pdf conversion and more other.");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentPage->SetFont("Arial", TFontStyles() << fsBold << fsItalic, 14, 0, false );       // Set the paragraph font
        VPDF->CurrentParagraph->PrintText("VisPDFLib is a simple way for your software to manage PDF file creating.");
        VPDF->CurrentPage->SetFont("Arial", TFontStyles(), 14, 0, false );                       // Set the paragraph font
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->PrintText("VisPDFLib features canvas (HDC), which you can use to draw and display text as well as copy to and from other classes supporting canvas. Built-in text and picture compression feature makes it easy to reduce file size");
        VPDF->CurrentParagraph->PrintText("to minimum. In addition, VisPDFLib features EMF file import to display them in the document.");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentPage->SetFont("Arial", TFontStyles() << fsBold << fsItalic, 14, 0, false );        // Set the paragraph font
        VPDF->CurrentParagraph->PrintText("VisPDFLib allows to load an existing pdf files and edit them:");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->PrintText("- print and draw on the existing pdf file as on the canvas");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->PrintText("- add, delete and copy pages from other files");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->PrintText("- encrypt, sign an existing pdf files and much more...");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentPage->SetFont("Arial", TFontStyles(), 14, 0, false );                       // Set the paragraph font
        VPDF->CurrentParagraph->PrintText("Based on trusted and well tested technology, VisPDF Lib offers developers PDF processing in simple form. VisPDF Lib allows quickly generate customer invoices. Create password-protected financial reports. Easy create electronic");
        VPDF->CurrentParagraph->PrintText("books and helps for applications. Produce encrypted and digitally signed documents. Send secure email with file attachments. VisPDF Lib offers all that and much more!");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentPage->SetFont("Arial", TFontStyles() << fsBold << fsItalic, 14, 0, false );       // Set the paragraph font
        VPDF->CurrentParagraph->PrintText("Supported Delphi versions: D5, D6, D7, D2005, D2006, D2007");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->PrintText("C++ Builder versions: CB5, CB6, CB2006, CB2007");
        VPDF->CurrentParagraph->NewLine(); // Line break
        VPDF->CurrentParagraph->PrintText("Turbo Delphi and Turbo C++ Builder supported.");

    VPDF->EndParagraph();                 // Close the paragraph

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

⌨️ 快捷键说明

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