//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------
// This sample illustrates how to embed various raster image formats
// (e.g. TIFF, JPEG, JPEG2000, JBIG2, GIF, PNG, BMP, etc.) in a PDF document.
//
// Note: On Windows platform this sample utilizes GDI+ and requires GDIPLUS.DLL to
// be present in the system path.
//-----------------------------------------------------------------------------------
int main(int argc, char *argv[])
{
int ret = 0;
PDFNet::Initialize(LicenseKey);
// Relative path to the folder containing test files.
ElementWriter writer; // Used to write Elements to the page
Page page = doc.PageCreate(); // Start a new page
writer.Begin(page); // Begin writing to this page
// ----------------------------------------------------------
// Add JPEG image to the output file
PDF::Image img = PDF::Image::Create(doc, (input_path + "peppers.jpg").c_str());
Element element = f.CreateImage(img, 50, 500, img.GetImageWidth()/2, img.GetImageHeight()/2);
writer.WritePlacedElement(element);
doc.PagePushBack(page); // Add the page to the document page sequence
// ----------------------------------------------------------
// Embed a monochrome TIFF. Compress the image using lossy JBIG2 filter.
page = doc.PageCreate(PDF::Rect(0, 0, 612, 794));
writer.Begin(page); // begin writing to this page
// Note: encoder hints can be used to select between different compression methods.
// For example to instruct PDFNet to compress a monochrome image using JBIG2 compression.
ObjSet hint_set;
Obj enc=hint_set.CreateArray(); // Initialize encoder 'hint' parameter
enc.PushBackName("JBIG2");
enc.PushBackName("Lossy");