이 튜토리얼에서는 **C++를 사용하여 PPTX에 이미지 워터마크를 추가하는 방법을 배웁니다. C++의 간단한 API 인터페이스를 사용하여 PowerPoint 프레젠테이션에 로고, 서명 또는 모든 시각적 정보를 이미지 워터마크로 삽입할 수 있습니다. 이 기능은 Windows 또는 Linux 플랫폼에서 이미지 워터마크를 추가하기 위한 Microsoft PowerPoint 또는 응용 프로그램에 종속되지 않습니다.
C++를 사용하여 PPTX에 이미지 워터마크를 추가하는 단계
- NuGet 패키지 관리자 도구에서 Aspose.Slides for C++ 설치
- Aspose::Slides 네임스페이스에 대한 참조 추가
- Presentation Class를 사용하여 이미지 워터마크를 추가하기 위한 입력 PPTX 로드
- 이미지 워터마크 추가를 위해 모든 마스터 슬라이드에 PictureFrame 추가
- 변경되지 않도록 추가된 이미지 워터마크를 잠급니다.
- 출력 워터마크가 있는 PPTX 프레젠테이션 파일 저장
몇 줄의 간단한 코드로 *C++*의 PowerPoint에 이미지 워터마크를 삽입할 수 있습니다. 이 예는 PPT 파일 형식에도 적용됩니다.
C++를 사용하여 PPTX에 이미지 워터마크를 추가하는 코드
#pragma once | |
#include <iostream> | |
#include <DOM/Presentation.h> | |
#include <DOM/IMasterSlideCollection.h> | |
#include <DOM/IMasterSlide.h> | |
#include <DOM/IShapeCollection.h> | |
#include <DOM/IAutoShape.h> | |
#include <DOM/ShapeType.h> | |
#include <DOM/SlideSizeScaleType.h> | |
#include <DOM/SlideSize.h> | |
#include <DOM/ISlideSize.h> | |
#include <DOM/IFillFormat.h> | |
#include <DOM/IPictureFillFormat.h> | |
#include <DOM/PictureFillMode.h> | |
#include <DOM/ITextFrame.h> | |
#include <DOM/IPortionFormat.h> | |
#include <DOM/IParagraphCollection.h> | |
#include <DOM/IParagraph.h> | |
#include <DOM/IPortionCollection.h> | |
#include <DOM/IPortion.h> | |
#include <DOM/FillType.h> | |
#include <DOM/NullableBool.h> | |
#include <DOM/IColorFormat.h> | |
#include <DOM/AutoShapeLock.h> | |
#include <Export/SaveFormat.h> | |
#include <DOM/IPPImage.h> | |
#include <DOM/IImageCollection.h> | |
#include <DOM/IPictureFrame.h> | |
#include <drawing/Color.h> | |
#include <drawing/Size.h> | |
#include <drawing/size_f.h> | |
#include <system/io/file_mode.h> | |
#include <system/io/file_stream.h> | |
using namespace Aspose::Slides; | |
using namespace System; | |
using namespace System::Drawing; | |
using namespace System::IO; | |
class AddWatermarkEx | |
{ | |
public: | |
static void AddImageWatermark() | |
{ | |
// Load the input presentation for adding image watermark | |
SharedPtr<Presentation> WatermarkPresentation = MakeObject<Presentation>(u"SourceInput.pptx"); | |
String imageFilePath = u"Tulips.jpg"; | |
//SharedPtr<System::Drawing::Bitmap> bitmap = MakeObject<System::Drawing::Bitmap>(imageFilePath); | |
SharedPtr<FileStream> ImageStream = MakeObject<IO::FileStream>(imageFilePath, System::IO::FileMode::Open); | |
SharedPtr<IPPImage> image = WatermarkPresentation->get_Images()->AddImage(ImageStream); | |
// Accessing the master slides for adding image watermark | |
for (SharedPtr <IMasterSlide> masterSlide : WatermarkPresentation->get_Masters()) | |
{ | |
// Adding a Pptx image watermark shape | |
SharedPtr <IPictureFrame> PptxWatermark = masterSlide->get_Shapes()->AddPictureFrame(ShapeType::Rectangle, | |
WatermarkPresentation->get_SlideSize()->get_Size().get_Width() / 2 - 50, | |
WatermarkPresentation->get_SlideSize()->get_Size().get_Height() / 2 - 50, | |
200, 50, image); | |
// Set the fill type, fill format, and rotation angle of the shape | |
PptxWatermark->set_Rotation(325); | |
PptxWatermark->get_FillFormat()->set_FillType(FillType::Picture); | |
PptxWatermark->get_FillFormat()->get_PictureFillFormat()->set_PictureFillMode(PictureFillMode::Stretch); | |
// Locking Pptx image watermarked shape to be uneditable in PowerPoint | |
PptxWatermark->get_ShapeLock()->Lock(); | |
} | |
// Save output presentation with watermark image | |
WatermarkPresentation->Save(u"ImageWatermarkPresentation.pptx", Export::SaveFormat::Pptx); | |
} | |
}; |
지난 주제에서는 C++를 사용하여 PPTX에 초안 워터마크를 추가하는 방법에 대해 배웠습니다. 이 항목은 C++*를 사용하여 *pptx에 이미지 워터마크를 넣는 방법에 중점을 둡니다.