Aby pracować ze znaczkami w pliku PDF, użyjemy interfejsu API Aspose.PDF for C++, który jest bogatym w funkcje, wydajnym i łatwym w użyciu interfejsem API do manipulacji dokumentami dla platformy cpp. Otwórz menedżera pakietów NuGet, wyszukaj Aspose.pdf i zainstaluj. Można również użyć następującego polecenia z konsoli Menedżera pakietów.
PM > Install-Package Aspose.PDF.Cpp
Dodaj pieczęć do dokumentu PDF C++
Potrzebujesz Aspose.PDF for C++, aby wypróbować kod w swoim środowisku.
- Załaduj plik PDF z wystąpieniem dokumentu.
- Pobierz DocumentInfo za pomocą właściwości Document.info.
- Dostęp i wyświetlanie różnych właściwości Document.info.
Dodaj znaczek do PDF - C++
String _dataDir("C:\\Samples\\");
// String for input file name
String inputFileName("AddTextStamp.pdf");
String outputFileName("AddTextStamp_out.pdf");
// Open document
auto document = MakeObject<Document>(_dataDir + inputFileName);
// Create text stamp
auto textStamp =MakeObject<TextStamp>(u"Sample Stamp");
// Set whether stamp is background
textStamp->set_Background(true);
// Set origin
textStamp->set_XIndent(100);
textStamp->set_YIndent(100);
// Rotate stamp
textStamp->set_Rotate(Rotation::on90);
// Set text properties
textStamp->get_TextState()->set_Font(FontRepository::FindFont(u"Arial"));
textStamp->get_TextState()->set_FontSize(14.0F);
textStamp->get_TextState()->set_FontStyle(FontStyles::Bold);
textStamp->get_TextState()->set_FontStyle(FontStyles::Italic);
textStamp->get_TextState()->set_ForegroundColor(Color::get_Green());
// Add stamp to particular page
document->get_Pages()->idx_get(1)->AddStamp(textStamp);
// Save output document
document->Save(_dataDir + outputFileName);