Last active
March 18, 2021 12:00
-
-
Save aspose-com-gists/93276a7077c995408e36ef974aa241d5 to your computer and use it in GitHub Desktop.
Split PDF files using C++
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
Split PDF file using Aspose.PDF for C++ API |
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
// Load PDF file | |
auto pdfDocument = MakeObject<Document>(u"SourceDirectory\\Sample 1.pdf"); | |
// Page counter | |
int pageCount = 1; | |
// Loop through all the pages | |
for (auto page : pdfDocument->get_Pages()) | |
{ | |
// Create new document | |
auto newDoc = MakeObject<Document>(); | |
// Add page to the document | |
newDoc->get_Pages()->Add(page); | |
// Save as PDF | |
newDoc->Save(u"OutputDirectory\\Sample_Page_" + System::Convert::ToString(pageCount) + u"_out.pdf"); | |
pageCount++; | |
} |
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
// Load PDF file | |
auto pdfDocument = MakeObject<Document>(u"SourceDirectory\\Sample 1.pdf"); | |
// Create new document | |
auto newDoc = MakeObject<Document>(); | |
// Page counter | |
int pageCount = 1; | |
// Loop through all the pages | |
for (auto page : pdfDocument->get_Pages()) | |
{ | |
// Get only even pages | |
if (pageCount % 2 == 0) | |
{ | |
// Add page to the document | |
newDoc->get_Pages()->Add(page); | |
} | |
pageCount++; | |
} | |
// Save as PDF | |
newDoc->Save(u"OutputDirectory\\Sample_Even_Pages_out.pdf"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment