-
Notifications
You must be signed in to change notification settings - Fork 5
feat: update PdfFileEditor article #518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marat-khazin-aspose
wants to merge
9
commits into
master
Choose a base branch
from
feature/update_pdffileeditor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
abff8f4
revert of adding Fix for page Formatting PDF Document:
marat-khazin-aspose e23e764
Added missing articles in documentation section of Aspose.PDF for Jav…
marat-khazin-aspose ec7991b
Update en/java/working-with-facades/pdffileeditor/make-nup-of-pdf-fil…
marat-khazin-aspose 14c0192
Update en/java/working-with-facades/pdffileeditor/make-nup-of-pdf-fil…
marat-khazin-aspose b31c38d
Update en/java/working-with-facades/pdffileeditor/make-booklet-of-pdf…
marat-khazin-aspose 0311870
Update en/java/working-with-facades/pdffileeditor/delete-pdf-pages/_i…
marat-khazin-aspose 1d5a580
Update en/java/working-with-facades/pdffileeditor/_index.md
marat-khazin-aspose d2b002d
Update en/java/working-with-facades/pdffileeditor/delete-pdf-pages/_i…
marat-khazin-aspose 70a006f
Update en/java/working-with-facades/pdffileeditor/delete-pdf-pages/_i…
marat-khazin-aspose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
63 changes: 63 additions & 0 deletions
63
en/java/working-with-facades/pdffileeditor/delete-pdf-pages/_index.md
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| --- | ||
| title: Delete PDF pages | ||
| type: docs | ||
| ai_search_scope: pdf_java | ||
| ai_search_endpoint: https://docsearch.api.aspose.cloud/ask | ||
marat-khazin-aspose marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| weight: 70 | ||
| url: /java/delete-pdf-pages/ | ||
| description: This section explains how to delete PDF pages with Aspose.PDF Facades using PdfFileEditor class. | ||
| lastmod: "2025-12-11" | ||
| draft: false | ||
| --- | ||
|
|
||
| If you want to delete a number of pages from the PDF file which is residing on the disk then you can use the overload of the | ||
| [Delete]method which takes following three parameters: intput file path, array of page numbers to be deleted, and output PDF file path. The second parameter is an integer array representing all of the pages which need to be deleted. The specified pages are removed from the intput file and the result is saved as output file. The following code snippet shows you how to delete PDF pages using file paths. | ||
marat-khazin-aspose marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ```java | ||
|
|
||
| private static void deletePages() | ||
| { | ||
| // The path to the documents directory | ||
| String dataDir = getDirectory(); | ||
| // Create PdfFileEditor object | ||
| com.aspose.pdf.facades.PdfFileEditor pdfEditor = new com.aspose.pdf.facades.PdfFileEditor(); | ||
| // Array of pages to delete | ||
| int[] pagesToDelete = new int[] { 1, 2 }; | ||
| // Delete pages | ||
| pdfEditor.delete(dataDir + "DeletePagesInput.pdf", pagesToDelete, dataDir + "DeletePagesUsingFilePath_out.pdf"); | ||
|
|
||
| } | ||
| ``` | ||
|
|
||
| ## Delete PDF Pages Using Streams | ||
|
|
||
| The `Delete` method of `PdfFileEditor` class also provides an overload which allows you to delete the pages from the input PDF file, while both the input and output files are in the streams. | ||
| This overload takes following three parameters: input stream, integer array of PDF pages to be deleted, and output stream. | ||
| The following code snippet shows you how to delete PDF pages using streams. | ||
|
|
||
| ```java | ||
|
|
||
| private static void deletePagesUsingStreams() | ||
| { | ||
| // The path to the documents directory | ||
| String dataDir = getDirectory(); | ||
|
|
||
| // Create PdfFileEditor object | ||
| com.aspose.pdf.facades.PdfFileEditor pdfEditor = new com.aspose.pdf.facades.PdfFileEditor(); | ||
| // Create streams | ||
| try (FileInputStream inputStream = new FileInputStream(dataDir + "DeletePagesInput.pdf")) | ||
| { | ||
| try (FileOutputStream outputStream = new FileOutputStream(dataDir + "DeletePagesUsingStream_out.pdf")) | ||
| { | ||
| // Array of pages to delete | ||
| int[] pagesToDelete = new int[] { 1, 2 }; | ||
| // Delete pages | ||
| pdfEditor.delete(inputStream, pagesToDelete, outputStream); | ||
| } | ||
| } catch (FileNotFoundException e) { | ||
| throw new RuntimeException(e); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
| ``` | ||
123 changes: 123 additions & 0 deletions
123
en/java/working-with-facades/pdffileeditor/insert-pdf-pages/_index.md
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| --- | ||
| title: Insert PDF pages | ||
| type: docs | ||
| ai_search_scope: pdf_java | ||
marat-khazin-aspose marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ai_search_endpoint: https://docsearch.api.aspose.cloud/ask | ||
| weight: 50 | ||
| url: /java/insert-pdf-pages/ | ||
| description: This section explains how to insert PDF pages with com.aspose.pdf.facades using PdfFileEditor class. | ||
| lastmod: "2025-12-11" | ||
| draft: false | ||
| --- | ||
|
|
||
|
|
||
| ## Insert PDF Pages Between Two Numbers Using File Paths | ||
|
|
||
| A particular range of pages can be inserted from one PDF into another using [Insert] method of [PdfFileEditor] class. | ||
| In order to do that, you need an input PDF file in which you want to insert the pages, a port file from which the pages need to be taken for insertion, a location where the pages are to be inserted, and a range of pages of the port file which have to be inserted in the input PDF file. This range is specified with start page and end page parameters. Finally, the output PDF file is saved with the specified range of pages inserted in the input file. The following code snippet shows you how to insert PDF pages between two numbers using file streams. | ||
|
|
||
| ```java | ||
| private static void insertPdfPagesBetweenTwoNumbersUsingFilePaths() | ||
| { | ||
| // The path to the documents directory | ||
| String dataDir = "C:\\Workspace\\"; | ||
|
|
||
| // Create PdfFileEditor object | ||
| com.aspose.pdf.facades.PdfFileEditor pdfEditor = new com.aspose.pdf.facades.PdfFileEditor(); | ||
|
|
||
| // Insert pages | ||
| pdfEditor.insert( | ||
| dataDir + "MultiplePages.pdf", 1, | ||
| dataDir + "InsertPages.pdf", 2, 5, | ||
| dataDir + "InsertPagesBetweenNumbers_out.pdf"); | ||
| } | ||
| ``` | ||
|
|
||
| ## Insert Array of PDF Pages Using File Paths | ||
|
|
||
| If you want to insert some specified pages into another PDF file, then you can use an overload of the [Insert] method which requires an integer array of pages. | ||
| In this array, you can specify which particular pages you want to insert in the input PDF file. In order to do that, you need an input PDF file in which you want to insert the pages, a port file from which the pages need to be taken for insertion, a location where the pages are to be inserted, and integer array of the pages from port file which have to be inserted in the input PDF file. This array contains a list of particular pages which you’re interested to insert in the input PDF file. Finally, the output PDF file is saved with the specified array of pages inserted in the input file. | ||
| The following code snippet shows you how to insert array of PDF pages using file paths. | ||
|
|
||
| ```java | ||
|
|
||
| private static void insertArrayOfPdfPagesUsingFilePaths() | ||
| { | ||
| // The path to the documents directory | ||
| String dataDir = "C:\\Workspace\\"; | ||
|
|
||
| // Create PdfFileEditor object | ||
| com.aspose.pdf.facades.PdfFileEditor pdfEditor = new com.aspose.pdf.facades.PdfFileEditor(); | ||
|
|
||
| int[] pagesToInsert = new int[] { 2, 3 }; | ||
| // Insert pages | ||
| pdfEditor.insert( | ||
| dataDir + "MultiplePages.pdf", 1, | ||
| dataDir + "InsertPages.pdf", pagesToInsert, | ||
| dataDir + "InsertArrayOfPages_out.pdf"); | ||
| } | ||
| ``` | ||
|
|
||
| ## Insert PDF Pages between Two Numbers Using Streams | ||
|
|
||
| If you want to insert the range of pages using streams, you only need to use the appropriate overload of the [Insert] method of [PdfFileEditor] class. | ||
| In order to do that, you need an input PDF stream in which you want to insert the pages, a port stream from which the pages need to be taken for insertion, a location where the pages are to be inserted, and a range of pages of the port stream which have to be inserted in the input PDF stream. This range is specified with start page and end page parameters. Finally, the output PDF stream is saved with the specified range of pages inserted in the input stream. The following code snippet shows you how to insert PDF pages between two numbers using streams. | ||
|
|
||
| ```java | ||
|
|
||
| private static void insertPdfPagesBetweenTwoNumbersUsingStreams() | ||
| { | ||
| // The path to the documents directory | ||
| String dataDir = "C:\\Workspace\\"; | ||
|
|
||
| // Create PdfFileEditor object | ||
| com.aspose.pdf.facades.PdfFileEditor pdfEditor = new com.aspose.pdf.facades.PdfFileEditor(); | ||
|
|
||
| // Create streams | ||
| try (FileInputStream inputStream = new FileInputStream(dataDir + "MultiplePages.pdf")) | ||
| { | ||
| try (FileInputStream portStream = new FileInputStream(dataDir + "InsertPages.pdf")) | ||
| { | ||
| try (FileOutputStream outputStream = new FileOutputStream(dataDir + "InsertPagesBetweenNumbersUsingStreams_out.pdf")) | ||
| { | ||
| // Insert pages | ||
| pdfEditor.insert(inputStream, 1, portStream, 1, 4, outputStream); | ||
| } | ||
| } | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Insert Array of PDF Pages Using Streams | ||
|
|
||
| You can also insert an array of pages into another PDF file using streams with the helps of appropriate overload of the Insert method which requires an integer array of pages. In this array, you can specify which particular pages you want to insert in the input PDF stream. In order to do that, you need an input PDF stream in which you want to insert the pages, a port stream from which the pages need to be taken for insertion, a location where the pages are to be inserted, and integer array of the pages from port stream which have to be inserted in the input PDF file. This array contains a list of particular pages which you’re interested to insert in the input PDF stream. Finally, the output PDF stream is saved with the specified array of pages inserted in the input file.The following code snippet shows you how to insert array of PDF pages using streams. | ||
|
|
||
| ```java | ||
|
|
||
| private static void insertArrayOfPdfPagesUsingStreams() | ||
| { | ||
| // The path to the documents directory | ||
| String dataDir = "C:\\Workspace\\"; | ||
|
|
||
| // Create PdfFileEditor object | ||
| com.aspose.pdf.facades.PdfFileEditor pdfEditor = new com.aspose.pdf.facades.PdfFileEditor(); | ||
| // Pages to insert | ||
| int[] pagesToInsert = new int[] { 2, 3 }; | ||
| // Create streams | ||
| try (FileInputStream inputStream = new FileInputStream(dataDir + "MultiplePages.pdf")) | ||
| { | ||
| try (FileInputStream portStream = new FileInputStream(dataDir + "InsertPages.pdf")) | ||
| { | ||
| try (FileOutputStream outputStream = new FileOutputStream(dataDir + "InsertPagesBetweenNumbersUsingStreams_out.pdf")) | ||
| { | ||
| // Insert pages | ||
| pdfEditor.insert(inputStream, 1, portStream, pagesToInsert, outputStream); | ||
| } | ||
| } | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.