Last active
April 1, 2020 10:47
-
-
Save aspose-pdf/e5fb9ddf5bd6460bb13d47fe5a83d86d to your computer and use it in GitHub Desktop.
This Gist contains examples of Aspose.Pdf for 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
Aspose.Pdf for 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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto editor = MakeObject<Facades::PdfContentEditor>(); | |
editor->BindPdf(L"..\\Data\\Annotations\\input.pdf"); | |
editor->CreateText(System::Drawing::Rectangle(400, 700, 100, 100), L"Title", L"Welcome to Aspose", true, L"Comment", 1); | |
editor->Save(L"..\\Data\\Annotations\\input_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
System::SharedPtr<Aspose::Pdf::Facades::PdfAnnotationEditor> editor = System::MakeObject<Aspose::Pdf::Facades::PdfAnnotationEditor>(); | |
// Load an existing PDF document | |
editor->BindPdf(L"..\\Data\\Annotations\\DeleteAllAnnotations.pdf"); | |
// Delete All Annotations | |
editor->DeleteAnnotations(); | |
// Save the document | |
editor->Save(L"..\\Data\\Annotations\\DeleteAllAnnotations_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
System::SharedPtr<Aspose::Pdf::Facades::PdfAnnotationEditor> editor = System::MakeObject<Aspose::Pdf::Facades::PdfAnnotationEditor>(); | |
// Load an existing PDF document | |
editor->BindPdf(L"..\\Data\\Annotations\\DeleteAllAnnotations.pdf"); | |
// Delete All Text Annotations | |
editor->DeleteAnnotations(L"Text"); | |
// Save the document | |
editor->Save(L"..\\Data\\Annotations\\DeleteAllAnnotations_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
System::SharedPtr<Aspose::Pdf::Facades::PdfAnnotationEditor> editor = System::MakeObject<Aspose::Pdf::Facades::PdfAnnotationEditor>(); | |
// Load Document where you want to import document | |
editor->BindPdf(L"..\\Data\\Annotations\\ExportAnnotations.pdf"); | |
System::ArrayPtr<System::String> annotTypes = System::MakeArray<System::String>({ L"Text", L"Highlight" }); | |
{ | |
System::SharedPtr<System::IO::Stream> stream = System::IO::File::Create(L"..\\Data\\Annotations\\Exported_out.xfdf"); | |
editor->ExportAnnotationsXfdf(stream, 1, 2, annotTypes); | |
} |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
System::SharedPtr<Aspose::Pdf::Facades::PdfAnnotationEditor> editor = System::MakeObject<Aspose::Pdf::Facades::PdfAnnotationEditor>(); | |
// Load Document where you want to import document | |
editor->BindPdf(L"..\\Data\\Annotations\\ExtractAnnotations.pdf"); | |
System::ArrayPtr<Aspose::Pdf::InteractiveFeatures::Annotations::AnnotationType> annotTypes = System::MakeArray<Aspose::Pdf::InteractiveFeatures::Annotations::AnnotationType>({ Aspose::Pdf::InteractiveFeatures::Annotations::AnnotationType::Text, Aspose::Pdf::InteractiveFeatures::Annotations::AnnotationType::Highlight }); | |
// Extract Annotations | |
System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<Aspose::Pdf::InteractiveFeatures::Annotations::Annotation>>> annotList = editor->ExtractAnnotations(1, 2, annotTypes); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
System::SharedPtr<Aspose::Pdf::Facades::PdfAnnotationEditor> editor = System::MakeObject<Aspose::Pdf::Facades::PdfAnnotationEditor>(); | |
// Load Document where you want to import document | |
editor->BindPdf(L"..\\Data\\Annotations\\ImportAnnotations.pdf"); | |
// Import annotations from XFDF file | |
editor->ImportAnnotationFromXfdf(L"..\\Data\\Annotations\\annotations.xfdf"); | |
// Save the document | |
editor->Save(L"..\\Data\\Annotations\\ImportAnnotations_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject <Aspose::Pdf::Document>(L"..\\Data\\Annotations\\input.pdf"); | |
System::SharedPtr<Aspose::Pdf::Facades::PdfAnnotationEditor> editor = System::MakeObject<Aspose::Pdf::Facades::PdfAnnotationEditor>(); | |
// Load an existing PDF document | |
editor->BindPdf(doc); | |
// Create an annotation object | |
System::SharedPtr<Aspose::Pdf::InteractiveFeatures::Annotations::TextAnnotation> annot = System::MakeObject<Aspose::Pdf::InteractiveFeatures::Annotations::TextAnnotation>(doc->get_Pages()->idx_get(1), MakeObject<Aspose::Pdf::Rectangle>(200, 400, 400, 600)); | |
// Set modified date | |
annot->set_Modified(System::DateTime::get_Now()); | |
// Set Title | |
annot->set_Title(L"NEW AUTHOR"); | |
// Set Content | |
annot->set_Contents(L"NEW CONTENTS"); | |
// Set Color | |
annot->set_Color(Color::get_Red()); | |
// Set Object | |
annot->set_Subject(L"NEW SUBJECT"); | |
// Set open flag | |
annot->set_Open(true); | |
// Modify Annotation | |
editor->ModifyAnnotations(1, 1, annot); | |
// Save the document | |
editor->Save(L"..\\Data\\Annotations\\output_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Create text file | |
System::IO::File::WriteAllText(L"..\\Data\\Attachments\\Attachment.txt", L"Some info"); | |
SharedPtr<FileSpecification> fileSpecification = MakeObject<FileSpecification>(L"..\\Data\\Attachments\\Attachment.txt", L"Sample text file"); | |
// Add attachment to document's attachment collection | |
auto doc = MakeObject<Document>(); | |
doc->get_EmbeddedFiles()->Add(fileSpecification); | |
doc->get_Pages()->Add(); | |
doc->Save(L"..\\Data\\Attachments\\Attachment.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Attachments\\DeleteAllAttachments.pdf"); | |
// Delete all attachments | |
doc->get_EmbeddedFiles()->Delete(); | |
// Save updated file | |
doc->Save(L"..\\Data\\Attachments\\DeleteAllAttachments_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
System::SharedPtr<Aspose::Pdf::Facades::PdfBookmarkEditor> editor = System::MakeObject<Aspose::Pdf::Facades::PdfBookmarkEditor>(); | |
// Load an existing PDF document | |
editor->BindPdf(L"..\\Data\\Bookmarks\\AddBookmark.pdf"); | |
// Create Bookmark | |
editor->CreateBookmarkOfPage(L"bookmark for page 1", 1); | |
// Save the document | |
editor->Save(L"..\\Data\\Bookmarks\\AddBookmark_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
System::SharedPtr<Aspose::Pdf::Facades::PdfBookmarkEditor> editor = System::MakeObject<Aspose::Pdf::Facades::PdfBookmarkEditor>(); | |
// Load an existing PDF document | |
editor->BindPdf(L"..\\Data\\Bookmarks\\AddChildBookmark.pdf"); | |
System::SharedPtr<Aspose::Pdf::Facades::Bookmark> bm1 = System::MakeObject<Aspose::Pdf::Facades::Bookmark>(); | |
bm1->set_PageNumber(1); | |
bm1->set_Title(L"First child"); | |
System::SharedPtr<Aspose::Pdf::Facades::Bookmark> bm2 = System::MakeObject<Aspose::Pdf::Facades::Bookmark>(); | |
bm2->set_PageNumber(2); | |
bm2->set_Title(L"Second child"); | |
System::SharedPtr<Aspose::Pdf::Facades::Bookmark> bm = System::MakeObject<Aspose::Pdf::Facades::Bookmark>(); | |
bm->set_Action(L"GoTo"); | |
bm->set_PageNumber(1); | |
bm->set_Title(L"Parent"); | |
System::SharedPtr<Aspose::Pdf::Facades::Bookmarks> bms = System::MakeObject<Aspose::Pdf::Facades::Bookmarks>(); | |
bms->Add(bm1); | |
bms->Add(bm2); | |
bm->set_ChildItem(bms); | |
editor->CreateBookmarks(bm); | |
// Save the document | |
editor->Save(L"..\\Data\\Bookmarks\\AddChildBookmark_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
System::SharedPtr<Aspose::Pdf::Facades::PdfBookmarkEditor> editor = System::MakeObject<Aspose::Pdf::Facades::PdfBookmarkEditor>(); | |
// Load an existing PDF document | |
editor->BindPdf(L"..\\Data\\Bookmarks\\DeleteAllBookmarks.pdf"); | |
// Delete All Bookmarks | |
editor->DeleteBookmarks(); | |
// Save the document | |
editor->Save(L"..\\Data\\Bookmarks\\DeleteAllBookmarks_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
System::SharedPtr<Aspose::Pdf::Facades::PdfBookmarkEditor> editor = System::MakeObject<Aspose::Pdf::Facades::PdfBookmarkEditor>(); | |
// Load an existing PDF document | |
editor->BindPdf(L"..\\Data\\Bookmarks\\DeleteParticularBookmark.pdf"); | |
// Delete Particular Bookmarks | |
editor->DeleteBookmarks(L"Parent Outline"); | |
// Save the document | |
editor->Save(L"..\\Data\\Bookmarks\\DeleteParticularBookmark_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto pages = doc->get_Pages(); | |
pages->Add(); | |
auto page = pages->idx_get(1); | |
auto stream = MakeObject<IO::MemoryStream>(); | |
SharedPtr<Bitmap> bitmap = MakeObject<Bitmap>(200, 200); | |
SharedPtr<Graphics> graphics = Graphics::FromImage(bitmap); | |
graphics->Clear(System::Drawing::Color::get_Yellow()); | |
graphics->FillRectangle(Brushes::get_Blue(), System::Drawing::Rectangle(0, 0, 200, 100)); | |
bitmap->Save(stream, Imaging::ImageFormat::get_Bmp()); | |
double x = 100.0, y = 600.0, width = 200.0, height = 200.0; | |
auto rect = MakeObject<Aspose::Pdf::Rectangle>(x, y, x + width, y + height); | |
stream->Seek(0, System::IO::SeekOrigin::Begin); | |
page->AddImage(stream, rect); | |
doc->Save(L"..\\Data\\Document\\Document_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto pages = doc->get_Pages(); | |
pages->Add(); | |
pages->Add(); | |
auto p2 = pages->idx_get(2); | |
auto dest = MakeObject<InteractiveFeatures::FitExplicitDestination>(p2); | |
auto action = MakeObject<InteractiveFeatures::GoToAction>(dest); | |
doc->set_OpenAction(action); | |
doc->Save(L"..\\Data\\Document\\Document.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto page = doc->get_Pages()->Add(); | |
auto fragment = MakeObject<TextFragment>(L""); | |
auto segment = MakeObject<TextSegment>(L"This is a sample text using Custom font."); | |
auto ts = MakeObject<TextState>(); | |
ts->set_Font(FontRepository::FindFont(L"Arial")); | |
ts->get_Font()->set_IsEmbedded(true); | |
segment->set_TextState(ts); | |
fragment->get_Segments()->Add(segment); | |
page->get_Paragraphs()->Add(fragment); | |
doc->Save(L"..\\Data\\Document\\EmbedFont.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
Console::WriteLine(L"Default values:"); | |
Console::WriteLine(L"CenterWindow : {0}", Convert::ToString(doc->get_CenterWindow())); | |
Console::WriteLine(L"Direction : {0}", DirectionConverter::ToString(doc->get_Direction())); | |
Console::WriteLine(L"DisplayDocTitle : {0}", Convert::ToString(doc->get_DisplayDocTitle())); | |
Console::WriteLine(L"FitWindow : {0}", Convert::ToString(doc->get_FitWindow())); | |
Console::WriteLine(L"HideMenuBar : {0}", Convert::ToString(doc->get_HideMenubar())); | |
Console::WriteLine(L"HideToolBar : {0}", Convert::ToString(doc->get_HideToolBar())); | |
Console::WriteLine(L"HideWindowUI : {0}", Convert::ToString(doc->get_HideWindowUI())); | |
Console::WriteLine(L"NonFullScreenPageMode : {0}", DOM::PageModeConverter::ToString(doc->get_NonFullScreenPageMode())); | |
Console::WriteLine(L"PageLayout : {0}", PageLayoutConverter::ToString(doc->get_PageLayout())); | |
Console::WriteLine(L"pageMode : {0}", DOM::PageModeConverter::ToString(doc->get_PageMode())); | |
doc->set_CenterWindow(true); | |
doc->set_Direction(Direction::R2L); | |
doc->set_DisplayDocTitle(true); | |
doc->set_FitWindow(true); | |
doc->set_HideMenubar(true); | |
doc->set_HideToolBar(true); | |
doc->set_HideWindowUI(true); | |
doc->set_PageLayout(PageLayout::TwoColumnLeft); | |
doc->set_NonFullScreenPageMode(DOM::PageMode::UseOC); | |
doc->set_PageMode(DOM::PageMode::UseThumbs); | |
doc->get_Pages()->Add(); | |
doc->get_Pages()->Add(); | |
doc->get_Pages()->Add(); | |
doc->Save(L"..\\Data\\Document\\DocWindowProperties.pdf"); | |
doc = MakeObject<Document>(L"..\\Data\\Document\\DocWindowProperties.pdf"); | |
Console::WriteLine(L"Updated values:"); | |
Console::WriteLine(L"CenterWindow : {0}", Convert::ToString(doc->get_CenterWindow())); | |
Console::WriteLine(L"Direction : {0}", DirectionConverter::ToString(doc->get_Direction())); | |
Console::WriteLine(L"DisplayDocTitle : {0}", Convert::ToString(doc->get_DisplayDocTitle())); | |
Console::WriteLine(L"FitWindow : {0}", Convert::ToString(doc->get_FitWindow())); | |
Console::WriteLine(L"HideMenuBar : {0}", Convert::ToString(doc->get_HideMenubar())); | |
Console::WriteLine(L"HideToolBar : {0}", Convert::ToString(doc->get_HideToolBar())); | |
Console::WriteLine(L"HideWindowUI : {0}", Convert::ToString(doc->get_HideWindowUI())); | |
Console::WriteLine(L"NonFullScreenPageMode : {0}", DOM::PageModeConverter::ToString(doc->get_NonFullScreenPageMode())); | |
Console::WriteLine(L"PageLayout : {0}", PageLayoutConverter::ToString(doc->get_PageLayout())); | |
Console::WriteLine(L"pageMode : {0}", DOM::PageModeConverter::ToString(doc->get_PageMode())); | |
Console::WriteLine(L"Get/Set document window properties finished."); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto info = doc->get_Info(); | |
// Set document information | |
info->set_Author(L"Naeem Akram"); | |
info->set_Subject(L"Working with Document Info"); | |
info->set_Title(L"Get/set document's info"); | |
// Save document | |
doc->get_Pages()->Add(); | |
doc->Save(L"..\\Data\\Document\\DocumentInfo.pdf"); | |
info.reset(); | |
doc = MakeObject<Document>(L"..\\Data\\Document\\DocumentInfo.pdf"); | |
info = doc->get_Info(); | |
// Get document information | |
Console::WriteLine(L"Author: {0}", info->get_Author()); | |
Console::WriteLine(L"Subject: {0}", info->get_Subject()); | |
Console::WriteLine(L"Title: {0}", info->get_Title()); | |
Console::WriteLine(L"Get/Set document's info finished."); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto md = doc->get_Metadata(); | |
md->idx_set(L"xmp:CreateDate", MakeObject<Engine::Data::XMP::XmpValue>(DateTime::get_Now())); | |
md->idx_set(L"xmp:CustomProperty", MakeObject<Engine::Data::XMP::XmpValue>(L"Custom Value")); | |
doc->get_Pages()->Add(); | |
doc->Save(L"..\\Data\\Document\\Metadata.pdf"); | |
doc = MakeObject<Document>(L"..\\Data\\Document\\Metadata.pdf"); | |
md = doc->get_Metadata(); | |
Console::WriteLine(L"CreateDate: {0}", md->idx_get(L"xmp:CreateDate")); | |
Console::WriteLine(L"CustomProperty: {0}", md->idx_get(L"xmp:CustomProperty")); | |
Console::WriteLine(L"Get/Set document metadata finished."); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(L"..\\Data\\Document\\Zoomed_pdf.pdf"); | |
// Create GoToAction object | |
//auto *action = static_cast<InteractiveFeatures::GoToAction*>(doc->get_OpenAction()); | |
//auto destination = static_cast<InteractiveFeatures::XYZExplicitDestination>(action->get_Destination()); | |
// Get the Zoom factor of PDF file | |
//Console::WriteLine(destination->get_Zoom()); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Document\\OptimizeDocument.pdf"); | |
// Optimize document | |
doc->Optimize(); | |
// Save updated document | |
doc->Save(L"..\\Data\\Document\\OptimizeDocument_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto pages = doc->get_Pages(); | |
pages->Add(); | |
doc->set_OpenAction(MakeObject<InteractiveFeatures::GoToAction>(MakeObject<InteractiveFeatures::XYZExplicitDestination>(1, 0, 0, .5))); | |
doc->Save(L"..\\Data\\Document\\Document.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Document\\ValidatePDFAStandard.pdf"); | |
// Validate PDF for PDF/A-1a | |
doc->Validate(L"..\\Data\\Document\\validation-result-A1A.xml", PdfFormat::PDF_A_1B); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Document\\ValidatePDFAStandard.pdf"); | |
// Validate PDF for PDF/A-1a | |
doc->Validate(L"..\\Data\\Document\\validation-result-A1A.xml", PdfFormat::PDF_A_1A); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto contentEditor = MakeObject<Facades::PdfContentEditor>(); | |
contentEditor->BindPdf(L"..\\Data\\Images\\DeleteAllImages.pdf"); | |
// Delete images | |
contentEditor->DeleteImage(); | |
contentEditor->Save(L"..\\Data\\Images\\DeleteAllImages_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto contentEditor = MakeObject<Facades::PdfContentEditor>(); | |
contentEditor->BindPdf(L"..\\Data\\Images\\DeleteImages-Page.pdf"); | |
auto imageIndex = MakeObject<System::ArrayPtr<int>>(1); | |
imageIndex[0] = 2; | |
// Delete the images from the particular page | |
contentEditor->DeleteImage(2, imageIndex); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto pdfExtractor = MakeObject<Facades::PdfExtractor>(); | |
pdfExtractor->BindPdf(L"..\\Data\\Images\\ExtractImages.pdf"); | |
// Extract all the images | |
pdfExtractor->ExtractImage(); | |
while (pdfExtractor->HasNextImage()) | |
{ | |
pdfExtractor->GetNextImage(L"..\\Data\\Images\\extractImage_out.jpg"); | |
} |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto pdfExtractor = MakeObject<Facades::PdfExtractor>(); | |
pdfExtractor->BindPdf(L"..\\Data\\Images\\ExtractImages.pdf"); | |
// Set StartPage and EndPage properties to the page number to you want to extract images from | |
pdfExtractor->set_StartPage(2); | |
pdfExtractor->set_EndPage(2); | |
// Extract images | |
pdfExtractor->ExtractImage(); | |
while (pdfExtractor->HasNextImage()) | |
{ | |
pdfExtractor->GetNextImage(L"..\\Data\\Images\\extractImage_out.jpg"); | |
} |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto contentEditor = MakeObject<Facades::PdfContentEditor>(); | |
contentEditor->BindPdf(L"..\\Data\\Images\\ReplaceImage.pdf"); | |
// Replace image on a particular page | |
contentEditor->ReplaceImage(1, 1, L"..\\Data\\Images\\aspose-logo.jpg"); | |
// Save output PDF | |
contentEditor->Save(L"..\\Data\\Images\\ReplaceImage_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open first document | |
auto doc1 = MakeObject<Document>(L"..\\Data\\Pages\\Concat1.pdf"); | |
// Open second document | |
auto doc2 = MakeObject<Document>(L"..\\Data\\Pages\\Concat2.pdf"); | |
// Add pages of second document to the first | |
doc1->get_Pages()->Add(doc2->get_Pages()); | |
// Save concatenated output file | |
doc1->Save(L"..\\Data\\Pages\\ConcatenatePdfFiles_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Pages\\DeleteParticularPage.pdf"); | |
// Delete a particular page | |
doc->get_Pages()->Delete(2); | |
// Save updated PDF | |
doc->Save(L"..\\Data\\Pages\\DeleteParticularPage_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Pages\\GetNumberofPages.pdf"); | |
// Get page count | |
Console::WriteLine(L"Page Count : {0}", doc->get_Pages()->get_Count()); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Pages\\GetProperties.pdf"); | |
// Get particular page from pages collection | |
auto pdfPage = doc->get_Pages()->idx_get(1); | |
// Get page properties | |
Console::WriteLine(L"MediaBox : Height={0},Width={1},LLX={2},LLY={3},URX={4},URY={5}", pdfPage->get_MediaBox()->get_Height(), pdfPage->get_MediaBox()->get_Width(), pdfPage->get_MediaBox()->get_LLY(), pdfPage->get_MediaBox()->get_URX(), pdfPage->get_MediaBox()->get_URY()); | |
Console::WriteLine(L"TrimBox : Height={0},Width={1},LLX={2},LLY={3},URX={4},URY={5}", pdfPage->get_TrimBox()->get_Height(), pdfPage->get_TrimBox()->get_Width(), pdfPage->get_TrimBox()->get_LLX(), pdfPage->get_TrimBox()->get_LLY(), pdfPage->get_TrimBox()->get_URX(), pdfPage->get_TrimBox()->get_URY()); | |
Console::WriteLine(L"Rect : Height={0},Width={1},LLX={2},LLY={3},URX={4},URY={5}", pdfPage->get_Rect()->get_Height(), pdfPage->get_Rect()->get_Width(), pdfPage->get_Rect()->get_LLX(), pdfPage->get_Rect()->get_LLY(), pdfPage->get_Rect()->get_URX(), pdfPage->get_Rect()->get_URY()); | |
Console::WriteLine(L"Page Number : {0}", pdfPage->get_Number()); | |
Console::WriteLine(L"Rotate : {0}", pdfPage->get_Rotate()); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Pages\\InsertEmptyPage.pdf"); | |
// Insert a empty page in a PDF | |
doc->get_Pages()->Insert(2); | |
// Save output file | |
doc->Save(L"..\\Data\\Pages\\InsertEmptyPage_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Pages\\InsertEmptyPageAtEnd.pdf"); | |
// Insert an empty page at the end of PDF file | |
doc->get_Pages()->Add(); | |
// Save output file | |
doc->Save(L"..\\Data\\Pages\\InsertEmptyPageAtEnd_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Pages\\SplitToPages.pdf"); | |
auto count = doc->get_Pages()->get_Count(); | |
int i; | |
for (i = 1; i <= count; ++i) | |
{ | |
SharedPtr<Page> pdfPage = doc->get_Pages()->idx_get(i); | |
auto newDoc = MakeObject<Document>(); | |
//newDoc->get_Pages()->Add(pdfPage); | |
newDoc->Save(L"..\\Data\\Text\\SplitToPages_out.pdf"); | |
} |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open document | |
auto doc = MakeObject<Document>(L"..\\Data\\Pages\\UpdateDimensions.pdf"); | |
// Set the page size as A4 (11.7 x 8.3 in) and in Aspose.Pdf, 1 inch = 72 points, so A4 dimensions in points will be (842.4, 597.6) | |
doc->get_Pages()->idx_get(1)->SetPageSize(842.4, 597.6); | |
// Save the updated document | |
doc->Save(L"..\\Data\\Pages\\UpdateDimensions_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Load an existing PDF document | |
auto doc = MakeObject<Document>(L"..\\Data\\SecurityAndSignatures\\ChangePassword.pdf", L"owner"); | |
// Decrypt PDF | |
doc->ChangePasswords(L"owner", L"newuser", L"newuser"); | |
// Save the updated document | |
doc->Save(L"..\\Data\\SecurityAndSignatures\\ChangePassword_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Load an existing PDF document | |
auto doc = MakeObject<Document>(L"..\\Data\\SecurityAndSignatures\\Decrypt.pdf", L"password"); | |
// Decrypt PDF | |
doc->Decrypt(); | |
// Save the updated document | |
doc->Save(L"..\\Data\\SecurityAndSignatures\\Decrypt_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Load an existing PDF document | |
auto doc = MakeObject<Document>(L"..\\Data\\SecurityAndSignatures\\input.pdf"); | |
// Way1: Using predefined privilege directly. | |
System::SharedPtr<Aspose::Pdf::Facades::DocumentPrivilege> privilege = Aspose::Pdf::Facades::DocumentPrivilege::get_Print(); | |
doc->Encrypt(L"user", L"owner", privilege, CryptoAlgorithm::AESx128, false); | |
doc->Save(L"..\\Data\\SecurityAndSignatures\\SetPrivelegesWay1_out.pdf"); | |
// Way2: Based on a predefined privilege and change some specifical permissions. | |
System::SharedPtr<Aspose::Pdf::Facades::DocumentPrivilege> privilege2 = Aspose::Pdf::Facades::DocumentPrivilege::get_AllowAll(); | |
privilege->set_AllowPrint(false); | |
privilege->set_AllowModifyContents(false); | |
doc->Encrypt(L"user", L"owner", privilege2, CryptoAlgorithm::AESx128, false); | |
doc->Save(L"..\\Data\\SecurityAndSignatures\\SetPrivelegesWay2_out.pdf"); | |
// Way3: Based on a predefined privilege and change some specifical Adobe Professional permissions combination. | |
System::SharedPtr<Aspose::Pdf::Facades::DocumentPrivilege> privilege3 = Aspose::Pdf::Facades::DocumentPrivilege::get_ForbidAll(); | |
privilege->set_ChangeAllowLevel(1); | |
privilege->set_PrintAllowLevel(2); | |
doc->Encrypt(L"user", L"owner", privilege3, CryptoAlgorithm::AESx128, false); | |
doc->Save(L"..\\Data\\SecurityAndSignatures\\SetPrivelegesWay3_out.pdf"); | |
// Way4: Mixes the way2 and way3 | |
System::SharedPtr<Aspose::Pdf::Facades::DocumentPrivilege> privilege4 = Aspose::Pdf::Facades::DocumentPrivilege::get_ForbidAll(); | |
privilege->set_ChangeAllowLevel(1); | |
privilege->set_AllowPrint(true); | |
doc->Encrypt(L"user", L"owner", privilege4, CryptoAlgorithm::AESx128, false); | |
doc->Save(L"..\\Data\\SecurityAndSignatures\\SetPrivelegesWay4_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto pages = doc->get_Pages(); | |
pages->Add(); | |
auto tb = MakeObject<TextBuilder>(pages->idx_get(1)); | |
auto text = MakeObject<TextFragment>(L"Hello world!"); | |
text->set_Position(MakeObject<Position>(100, 800)); | |
tb->AppendText(text); | |
text = MakeObject<TextFragment>(L"This example is created by Aspose.Pdf for C++."); | |
text->set_Position(MakeObject<Position>(100, 700)); | |
tb->AppendText(text); | |
text = MakeObject<TextFragment>(L"Demonstrates how to use TextBuilder to append text into pdf file."); | |
text->set_Position(MakeObject<Position>(200, 600)); | |
tb->AppendText(text); | |
auto par = MakeObject<TextParagraph>(); | |
par->set_Position(MakeObject<Position>(150, 400)); | |
par->AppendLine(L"New paragraph"); | |
par->AppendLine(L"Line 2"); | |
par->AppendLine(L"Line 3"); | |
tb->AppendParagraph(par); | |
doc->Save(L"..\\Data\\Text\\AddText.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto pages = doc->get_Pages(); | |
// Add page to pages collection of PDF file | |
pages->Add(); | |
auto tb = MakeObject<TextBuilder>(pages->idx_get(1)); | |
// Create TextFragment instance | |
auto tf = MakeObject<TextFragment>(L"Hello world!"); | |
tf->set_HorizontalAlignment(HorizontalAlignment::Right); | |
// Create a textsegment with sample text | |
auto segment = MakeObject<TextSegment>(L" ... Text Segment 1..."); | |
// Add segment to segments collection of TextFragment | |
tf->get_Segments()->Add(segment); | |
// Create a new TextSegment | |
segment = MakeObject<TextSegment>(L"Link to Google"); | |
// Add segment to segments collection of TextFragment | |
tf->get_Segments()->Add(segment); | |
// Set forground color for text segment | |
segment->get_TextState()->set_ForegroundColor(Aspose::Pdf::Color::get_Blue()); | |
// Set text formatting as italic | |
segment->get_TextState()->set_FontStyle(Aspose::Pdf::Text::FontStyles::Italic); | |
// Create another TextSegment object | |
segment = MakeObject<TextSegment>(L"TextSegment without hyperlink"); | |
// Add segment to segments collection of TextFragment | |
tf->get_Segments()->Add(segment); | |
tb->AppendText(tf); | |
auto par = MakeObject<TextParagraph>(); | |
par->set_Position(MakeObject<Position>(150, 400)); | |
par->AppendLine(L"New paragraph"); | |
par->AppendLine(L"Line 2"); | |
par->AppendLine(L"Line 3"); | |
tb->AppendParagraph(par); | |
doc->Save(L"..\\Data\\Text\\AddTextSegment_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto pages = doc->get_Pages(); | |
pages->Add(); | |
auto tb = MakeObject<TextBuilder>(pages->idx_get(1)); | |
auto text = MakeObject<TextFragment>(L"Hello world!"); | |
text->set_Position(MakeObject<Position>(100, 800)); | |
// Set the formatting of text as Underline | |
text->get_TextState()->set_Underline(true); | |
tb->AppendText(text); | |
auto par = MakeObject<TextParagraph>(); | |
par->set_Position(MakeObject<Position>(150, 400)); | |
par->AppendLine(L"New paragraph"); | |
par->AppendLine(L"Line 2"); | |
par->AppendLine(L"Line 3"); | |
tb->AppendParagraph(par); | |
doc->Save(L"..\\Data\\Text\\AddUnderlineText_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto pages = doc->get_Pages(); | |
pages->Add(); | |
auto page = pages->idx_get(1); | |
auto paragraps = page->get_Paragraphs(); | |
paragraps->Add(MakeObject<TextFragment>(L"Center alligned text")); | |
paragraps->Add(MakeObject<TextFragment>(L"Left alligned text.")); | |
paragraps->Add(MakeObject<TextFragment>(L"Right alligned text.")); | |
paragraps->Add(MakeObject<TextFragment>(L"This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified. This paragraph is justified.")); | |
paragraps->idx_get(0)->set_HorizontalAlignment(HorizontalAlignment::Center); | |
paragraps->idx_get(1)->set_HorizontalAlignment(HorizontalAlignment::Left); | |
paragraps->idx_get(2)->set_HorizontalAlignment(HorizontalAlignment::Right); | |
paragraps->idx_get(3)->set_HorizontalAlignment(HorizontalAlignment::Justify); | |
doc->Save(L"..\\Data\\Text\\Paragraph_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(); | |
auto pages = doc->get_Pages(); | |
pages->Add(); | |
// Numeration of Pages starts from 1 | |
auto page = pages->idx_get(1); | |
auto paragraps = page->get_Paragraphs(); | |
paragraps->Add(MakeObject<TextFragment>(L"Hello World!")); | |
auto text = MakeObject<TextFragment>(L"This example is created by Aspose.Pdf for C++."); | |
auto ts = text->get_TextState(); | |
ts->set_FontSize(16); | |
ts->set_FontStyle(FontStyles::Italic); | |
paragraps->Add(text); | |
doc->Save(L"..\\Data\\Text\\input_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto extractor = MakeObject<Facades::PdfExtractor>(); | |
extractor->BindPdf(L"..\\Data\\Text\\input.pdf"); | |
extractor->ExtractText(); | |
auto memStream = MakeObject<IO::MemoryStream>(); | |
extractor->GetText(memStream); | |
auto unicode = System::Text::Encoding::get_Unicode(); | |
String allText = unicode->GetString(memStream->ToArray()); | |
Console::WriteLine(allText); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto extractor = MakeObject<Facades::PdfExtractor>(); | |
extractor->BindPdf(L"..\\Data\\Text\\ExtractText-PageRange.pdf"); | |
// Specify start and end pages | |
extractor->set_StartPage(1); | |
extractor->set_EndPage(1); | |
// Use parameterless ExtractText method | |
extractor->ExtractText(); | |
auto memStream = MakeObject<IO::MemoryStream>(); | |
extractor->GetText(memStream); | |
auto unicode = System::Text::Encoding::get_Unicode(); | |
String allText = unicode->GetString(memStream->ToArray()); | |
Console::WriteLine(allText); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto doc = MakeObject<Document>(L"..\\Data\\Text\\input.pdf"); | |
auto absorber = MakeObject<TextFragmentAbsorber>(L"Aspose.Pdf"); | |
doc->get_Pages()->idx_get(1)->Accept(absorber); | |
// Numeration of TextFragments starts from 1 | |
auto ts = absorber->get_TextFragments()->idx_get(1)->get_TextState(); | |
ts->set_Font(FontRepository::FindFont(L"TimesNewRoman")); | |
ts->set_BackgroundColor(Aspose::Pdf::Color::get_Yellow()); | |
doc->Save(L"..\\Data\\Text\\input_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
auto ce = MakeObject<Facades::PdfContentEditor>(); | |
ce->BindPdf(L"..\\Data\\Text\\input.pdf"); | |
auto options = MakeObject<TextOptions::TextReplaceOptions>(TextOptions::TextReplaceOptions::Scope::REPLACE_FIRST); | |
ce->set_TextReplaceOptions(options); | |
ce->ReplaceText(L"example", L"file"); | |
ce->Save(L"..\\Data\\Text\\input_out.pdf"); |
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
For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-C | |
// Open input PDF | |
auto ce = MakeObject<Facades::PdfContentEditor>(); | |
ce->BindPdf(L"..\\Data\\Text\\ReplaceText-Page.pdf"); | |
// Replace text on particular pages | |
ce->ReplaceText(L"Hello", 1, L"World"); | |
ce->Save(L"..\\Data\\Text\\ReplaceTextOnParticularPage_out.pdf"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment