Last active
July 27, 2021 16:28
-
-
Save aspose-com-gists/1da17d20a8e3939c2a596646577e0370 to your computer and use it in GitHub Desktop.
Convert Images to PDF using C++ | https://blog.aspose.com/2021/06/24/convert-images-to-pdf-format-using-cpp/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Read the complete article about converting images to PDF format using C++ by visiting the following link. | |
https://blog.aspose.com/2021/06/24/convert-images-to-pdf-format-using-cpp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an instance of the Document class | |
auto pdfDocument = MakeObject<Document>(); | |
// Add a page | |
System::SharedPtr<Page> page = pdfDocument->get_Pages()->Add(); | |
// Set margins | |
page->get_PageInfo()->get_Margin()->set_Bottom(0); | |
page->get_PageInfo()->get_Margin()->set_Top(0); | |
page->get_PageInfo()->get_Margin()->set_Left(0); | |
page->get_PageInfo()->get_Margin()->set_Right(0); | |
// Set CropBox | |
page->set_CropBox(MakeObject<Aspose::Pdf::Rectangle>(0, 0, 400, 400)); | |
// Create an instance of the Image class | |
System::SharedPtr<Aspose::Pdf::Image> image = MakeObject<Aspose::Pdf::Image>(); | |
// Specify the image path | |
image->set_File(u"SourceDirectory\\Images\\AsposeLogo.png"); | |
// Add the image to the PDF page | |
page->get_Paragraphs()->Add(System::DynamicCast<BaseParagraph>(image)); | |
// Save the PDF file | |
pdfDocument->Save(u"OutputDirectory\\Image2PDF.pdf"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment