Skip to content

Instantly share code, notes, and snippets.

@aspose-pdf
Last active December 28, 2019 11:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save aspose-pdf/4a12f0ebd453e7f0d552ed6658ed3253 to your computer and use it in GitHub Desktop.
Save aspose-pdf/4a12f0ebd453e7f0d552ed6658ed3253 to your computer and use it in GitHub Desktop.
Aspose-Pdf-Facades
This gist exceeds the recommended number of files (~10). To access all files, please clone this gist.
Aspose-Pdf-Facades
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();
// Open document
PdfContentEditor contentEditor = new PdfContentEditor();
contentEditor.BindPdf(dataDir+ "AddFreeTextAnnotation.pdf");
// Create rectangle
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(50, 50, 100, 100);
// Create annotation
contentEditor.CreateFreeText(rect, "Sample content", 1);
// Save updated PDF file
contentEditor.Save(dataDir+ "AddFreeTextAnnotation_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();
// Instantiate PdfContentEditor object
PdfContentEditor editor = new PdfContentEditor();
// Bind input PDF file
editor.BindPdf(dataDir+ "CreateFileAnnotation.pdf");
// The last argumnet is for transparency of icon
editor.CreateFileAttachment(new System.Drawing.Rectangle(50, 50, 10, 10), "here", dataDir + "AddFreeTextAnnotation.pdf", 1, "Paperclip", 0.005);
// Save the updated PDF file
editor.Save(dataDir+ "PdfWith_Transparent_Annotation_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();
// Open document
PdfAnnotationEditor annotationEditor = new PdfAnnotationEditor();
annotationEditor.BindPdf(dataDir+ "DeleteAllAnnotations.pdf");
// Delete all annoations
annotationEditor.DeleteAnnotations();
// Save updated PDF
annotationEditor.Save(dataDir+ "DeleteAllAnnotations_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();
// Open document
PdfAnnotationEditor annotationEditor = new PdfAnnotationEditor();
annotationEditor.BindPdf(dataDir+ "DeleteAllAnnotations.pdf");
// Delete specific annoations
annotationEditor.DeleteAnnotations("Text");
// Save updated PDF
annotationEditor.Save(dataDir + "DeleteSpecificAnnotations_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();
// Create PdfAnnotationEditor object
PdfAnnotationEditor AnnotationEditor = new PdfAnnotationEditor();
// Open PDF document
AnnotationEditor.BindPdf(dataDir+ "ExportAnnotations.pdf");
// Export annotations
FileStream fileStream = new System.IO.FileStream(dataDir + "exportannotations.xfdf", System.IO.FileMode.Create);
Enum[] annotType = { AnnotationType.FreeText, AnnotationType.Line };
AnnotationEditor.ExportAnnotationsXfdf(fileStream, 1, 5, annotType);
// Save output PDF
AnnotationEditor.Save(dataDir+ "ExportAnnotations_out.pdf");
fileStream.Flush();
fileStream.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();
// Create PdfAnnotationEditor
PdfAnnotationEditor annotationEditor = new PdfAnnotationEditor();
// Open PDF document
annotationEditor.BindPdf(dataDir + "ExtractAnnotations.pdf");
// Extract annotations
Enum[] annotType = { AnnotationType.FreeText, AnnotationType.Line };
ArrayList annotList = (ArrayList)annotationEditor.ExtractAnnotations(1, 2, annotType);
for (int index = 0; index < annotList.Count; index++)
{
Annotation annotation = (Annotation)annotList[index];
Console.WriteLine(annotation.Contents);
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();
// Create PdfAnnotationEditor object
PdfAnnotationEditor AnnotationEditor = new PdfAnnotationEditor();
// Open PDF document
AnnotationEditor.BindPdf(dataDir+ "ImportAnnotations.pdf");
// Import annotations
FileStream fileStream = new System.IO.FileStream(dataDir+ "annotations.xfdf", System.IO.FileMode.Open, System.IO.FileAccess.Read);
Enum[] annotType = { AnnotationType.FreeText, AnnotationType.Line };
AnnotationEditor.ImportAnnotationFromXfdf(fileStream, annotType);
// Save output PDF
AnnotationEditor.Save(dataDir + "ImportAnnotations_out.pdf");
fileStream.Flush();
fileStream.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Annotations();
// Open document
Aspose.Pdf.Facades.PdfAnnotationEditor annotationEditor = new Aspose.Pdf.Facades.PdfAnnotationEditor();
annotationEditor.BindPdf( dataDir + "input.pdf");
// Create annotation
FreeTextAnnotation annotation = new FreeTextAnnotation(annotationEditor.Document.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600), new DefaultAppearance("TimesNewRoman", 14, System.Drawing.Color.Orange));
annotation.Modified = DateTime.Now;
annotation.Contents = "Contents...";
annotation.Subject = "Subject";
annotation.Color = Color.Green;
// Modify annotation
annotationEditor.ModifyAnnotations(1, 1, annotation);
// Save updated PDF file
annotationEditor.Save("output_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
// Open document
PdfContentEditor contentEditor = new PdfContentEditor();
contentEditor.BindPdf(dataDir+ "AddAttachment.pdf");
// Add attachment
contentEditor.AddDocumentAttachment(dataDir+ "test.txt", "Attachment Description");
// Save updated PDF
contentEditor.Save(dataDir+ "AddAttachment_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
// Open document
PdfContentEditor contentEditor = new PdfContentEditor();
contentEditor.BindPdf(dataDir+ "AddAttachment-Stream.pdf");
// Read file into stream (FileStream or MemoryStream)
FileStream fileStream = new FileStream(dataDir+ "test.txt", FileMode.Open);
// Add attachment
contentEditor.AddDocumentAttachment(fileStream, "Attachment Name", "Attachment Description");
// Save updated PDF
contentEditor.Save(dataDir+ "AddAttachment-Stream_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
// Open document
PdfContentEditor contentEditor = new PdfContentEditor();
contentEditor.BindPdf(dataDir+ "DeleteAllAttachments.pdf");
// Delete attachments
contentEditor.DeleteAttachments();
// Save updated PDF
contentEditor.Save(dataDir+ "DeleteAllAttachments_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
// Open document
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(dataDir+ "ExtractAllAttachments.pdf");
// Extract attachments
pdfExtractor.ExtractAttachment();
// Get extracted attachments
pdfExtractor.GetAttachment(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Attachments();
// Open document
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(dataDir+ "GetAttachmentNames.pdf");
// Extract attachments
pdfExtractor.ExtractAttachment();
// Get attachment names
System.Collections.IList attachmentNames = (System.Collections.IList)pdfExtractor.GetAttachNames();
foreach (string attachmentName in attachmentNames)
Console.WriteLine("Name : {0}", attachmentName);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Create bookmark
Bookmark boomark = new Bookmark();
boomark.PageNumber = 1;
boomark.Title = "New Bookmark";
// Create PdfBookmarkEditor class
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
// Bind PDF document
bookmarkEditor.BindPdf(dataDir+ "AddBookmark.pdf");
// Create bookmarks
bookmarkEditor.CreateBookmarks(boomark);
// Save updated document
bookmarkEditor.Save(dataDir+ "AddBookmark_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Create bookmarks
Aspose.Pdf.Facades.Bookmarks bookmarks = new Aspose.Pdf.Facades.Bookmarks();
Bookmark childBookmark1 = new Bookmark();
childBookmark1.PageNumber = 1;
childBookmark1.Title = "First Child";
Bookmark childBookmark2 = new Bookmark();
childBookmark2.PageNumber = 2;
childBookmark2.Title = "Second Child";
bookmarks.Add(childBookmark1);
bookmarks.Add(childBookmark2);
Bookmark bookmark = new Bookmark();
bookmark.Action = "GoTo";
bookmark.PageNumber = 1;
bookmark.Title = "Parent";
bookmark.ChildItems = bookmarks;
// Create PdfBookmarkEditor class
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
// Bind PDF document
bookmarkEditor.BindPdf(dataDir+ "AddChildBookmark.pdf");
// Create bookmarks
bookmarkEditor.CreateBookmarks(bookmark);
// Save updated document
bookmarkEditor.Save(dataDir+ "AddChildBookmark_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Open document
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
bookmarkEditor.BindPdf(dataDir+ "CreateBookmark-Page.pdf");
// Create bookmark of a particular page
bookmarkEditor.CreateBookmarkOfPage("Bookmark Name", 2);
// Save updated PDF file
bookmarkEditor.Save(dataDir+ "CreateBookmark-Page_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Open document
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
bookmarkEditor.BindPdf( dataDir + "CreateBookmark-Page.pdf");
// Bookmark name list
string[] bookmarkList = { "First" };
// Page list
int[] pageList = { 1 };
// Create bookmark of a range of pages
bookmarkEditor.CreateBookmarkOfPage(bookmarkList, pageList);
// Save updated PDF file
bookmarkEditor.Save( dataDir + "CreateBookmarkPageRange_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Open document
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
bookmarkEditor.BindPdf(dataDir+ "CreateBookmarksAll.pdf");
// Create bookmark of all pages
bookmarkEditor.CreateBookmarks();
// Save updated PDF file
bookmarkEditor.Save(dataDir+ "Output_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Open document
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
bookmarkEditor.BindPdf(dataDir+ "CreateBookmarks-PagesProperties.pdf");
// Create bookmark of all pages
bookmarkEditor.CreateBookmarks(System.Drawing.Color.Green, true, true);
// Save updated PDF file
bookmarkEditor.Save(dataDir+ "CreateBookmarks-PagesProperties_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Open document
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
bookmarkEditor.BindPdf(dataDir+ "DeleteABookmark.pdf");
// Delete bookmark
bookmarkEditor.DeleteBookmarks("Page2");
// Save updated PDF file
bookmarkEditor.Save(dataDir+ "DeleteABookmark_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Open document
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
bookmarkEditor.BindPdf(dataDir+ "DeleteAllBookmarks.pdf");
// Delete bookmark
bookmarkEditor.DeleteBookmarks();
// Save updated PDF file
bookmarkEditor.Save(dataDir+ "DeleteAllBookmarks_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Create PdfBookmarkEditor object
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
// Open PDF file
bookmarkEditor.BindPdf(dataDir+ "ExportToXML.pdf");
// Export bookmarks
bookmarkEditor.ExportBookmarksToXML(dataDir+ "bookmarks.xml");
// Save updated PDF
bookmarkEditor.Save(dataDir+ "ExportToXML_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Create PdfBookmarkEditor
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
// Open PDF file
bookmarkEditor.BindPdf(dataDir+ "ExtractBookmarks.pdf");
// Extract bookmarks
Aspose.Pdf.Facades.Bookmarks bookmarks = bookmarkEditor.ExtractBookmarks();
foreach (Bookmark bookmark in bookmarks)
{
Console.WriteLine("Title: {0}", bookmark.Title);
Console.WriteLine("Page Number: {0}", bookmark.PageNumber);
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Create PdfBookmarkEditor
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
// Open PDF file
bookmarkEditor.BindPdf(dataDir + "GetFromPDF.PDF");
// Extract bookmarks
Aspose.Pdf.Facades.Bookmarks bookmarks = bookmarkEditor.ExtractBookmarks();
foreach (Aspose.Pdf.Facades.Bookmark bookmark in bookmarks)
{
// Get the title information of bookmark item
Console.WriteLine("Title: {0}", bookmark.Title);
// Get the destination page for bookmark
Console.WriteLine("Page Number: {0}", bookmark.PageNumber);
// Get the information related to associated action with bookmark
Console.WriteLine("Bookmark Action: " + bookmark.Action);
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Create PdfBookmarkEditor class
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
// Open PDF file
bookmarkEditor.BindPdf(dataDir+ "ImportFromXML.pdf");
// Import bookmarks
bookmarkEditor.ImportBookmarksWithXML(dataDir+ "bookmarks.xml");
// Save updated PDF file
bookmarkEditor.Save(dataDir+ "ImportFromXML_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks();
// Open document
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
bookmarkEditor.BindPdf(dataDir+ "UpdateBookmark.pdf");
// Update bookmark
bookmarkEditor.ModifyBookmarks("New Bookmark", "New Title");
// Save updated PDF file
bookmarkEditor.Save(dataDir+ "UpdateBookmark_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
FormEditor formEditor = new FormEditor();
// Open Document
formEditor.BindPdf(dataDir+ "AddFormField.pdf");
// Add field
formEditor.AddField(FieldType.Text, "textfield", 1, 100, 100, 200, 150);
formEditor.AddField(FieldType.CheckBox, "checkboxfield", 1, 100, 200, 200, 250);
formEditor.AddField(FieldType.ComboBox, "comboboxfield", 1, 100, 300, 200, 350);
formEditor.AddField(FieldType.ListBox, "listboxfield", 1, 100, 400, 200, 450);
formEditor.AddField(FieldType.MultiLineText, "multilinetextfield", 1, 100, 500, 200, 550);
// Save updated file
formEditor.Save(dataDir+ "AddFormField_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
FormEditor form = new FormEditor();
// Open the document and create a FormEditor object
form.BindPdf(dataDir + "AddListItem.pdf");
// Add list field in PDF file
form.AddField(FieldType.ListBox, "listbox", 1, 300, 200, 350, 225);
// Add list items
form.AddListItem("listbox", "Item 1");
form.AddListItem("listbox", "Item 2");
// Add multiple list items once
string[] listItems = { "Item 3", "Item 4", "Item 5" };
form.AddListItem("listbox", listItems);
// Save updated file
form.Save(dataDir + "AddListItem_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
// Create FormEditor object
FormEditor formEditor = new FormEditor();
// Open Document
formEditor.BindPdf(dataDir + "CopyInnerField.pdf");
// Copy a field to another page
formEditor.CopyInnerField("textfield", "newfieldname", 1);
// Close and save the output document
formEditor.Save(dataDir + "CopyInnerField_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
// Open document
FormEditor formEditor = new FormEditor();
// Open the document and create a FormEditor object
formEditor.BindPdf(dataDir + "CopyOuterField.pdf");
// Copy a text field from one document to another one
formEditor.CopyOuterField( dataDir + "input.pdf", "textfield", 1);
// Close and save the output document
formEditor.Save(dataDir + "CopyOuterField_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
// Open document
FormEditor form = new FormEditor();
// Open the document and create a FormEditor object
form.BindPdf(dataDir + "DecorateFields.pdf");
// Create a new facade object
FormFieldFacade facade = new FormFieldFacade();
// Assign the facade to form editor
form.Facade = facade;
// Set the backgroud color as red
facade.BackgroundColor = System.Drawing.Color.Red;
// Set the alignment as center
facade.Alignment = FormFieldFacade.AlignCenter;
// All text fields will be modified:
form.DecorateField(FieldType.Text);
// Close and validate the modification like this:
form.Save(dataDir + "DecorateFields_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
FormEditor form = new FormEditor();
// Open the document and create a FormEditor object
form.BindPdf(dataDir + "input.pdf");
// Set field facade
FormFieldFacade fieldFacade = new FormFieldFacade();
form.Facade = fieldFacade;
fieldFacade.BackgroundColor = System.Drawing.Color.Red;
fieldFacade.FontSize = 14;
// Specify the form field which needs to be decorated
form.DecorateField("textfield");
// Save updated PDF form
form.Save(dataDir + "DecorateParticularField_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
FormEditor form = new FormEditor();
// Open the document and create a FormEditor object
form.BindPdf(dataDir + "input.pdf");
// Set field facade
FormFieldFacade fieldFacade = new FormFieldFacade();
form.Facade = fieldFacade;
fieldFacade.BackgroundColor = System.Drawing.Color.Red;
fieldFacade.FontSize = 14;
// Set font for form field
fieldFacade.CustomFont = "CourierNew";
// Specify the form field which needs to be decorated
form.DecorateField("textfield");
// Save updated PDF form
form.Save("SetFont_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
FormEditor formEditor = new FormEditor();
// Open Document
formEditor.BindPdf(dataDir + "DeleteFormField.pdf");
// Delete field
formEditor.RemoveField("textfield");
// Save updated file
formEditor.Save( dataDir + "DeleteFormField_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
FormEditor form = new FormEditor();
// Open the document and create a FormEditor object
form.BindPdf(dataDir + "AddListItem.pdf");
// Delete list item
form.DelListItem("listbox", "Item 2");
// Save updated file
form.Save(dataDir + "DeleteListItem_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
// Open Document
form.BindPdf(dataDir + "input.pdf");
// Create fdf file.
System.IO.FileStream fdfOutputStream = new FileStream(dataDir + "student.fdf", FileMode.Create);
// Export data
form.ExportFdf(fdfOutputStream);
// Close file stream
fdfOutputStream.Close();
// Save updated document
form.Save(dataDir + "ExportDataToPdf_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
// Open Document
form.BindPdf(dataDir + "input.pdf");
// Create xfdf file.
System.IO.FileStream xfdfOutputStream = new FileStream("student1.xfdf", FileMode.Create);
// Export data
form.ExportXfdf(xfdfOutputStream);
// Close file stream
xfdfOutputStream.Close();
// Save updated document
form.Save(dataDir + "ExportDataToXFDF_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
// Open document
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
form.BindPdf(dataDir + "input.pdf");
// Create xml file.
System.IO.FileStream xmlOutputStream = new FileStream( dataDir + "input.xml", FileMode.Create);
// Export data
form.ExportXml(xmlOutputStream);
// Close file stream
xmlOutputStream.Close();
// Close the document
form.Dispose();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
// Create Form Object
Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
// Open Document
pdfForm.BindPdf(dataDir + "FormField.pdf");
// Fill the field "textfield" with "Mike".
pdfForm.FillField("textfield", "Mike");
// Save updated file
pdfForm.Save( dataDir + "FillFormFieldF_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
// Open Document
pdfForm.BindPdf(dataDir + "input.pdf");
// Flatten fields
pdfForm.FlattenAllFields();
// Save output
pdfForm.Save( dataDir + "FlattenAllFields_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
// Create Form Object
Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
// Open Document
pdfForm.BindPdf(dataDir + "FormField.pdf");
// Get button option values
var optionValues = pdfForm.GetButtonOptionValues("Gender");
IDictionaryEnumerator optionValueEnumerator = optionValues.GetEnumerator();
while (optionValueEnumerator.MoveNext())
Console.WriteLine("Key : {0} , Value : {1} ", optionValueEnumerator.Key, optionValueEnumerator.Value);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
// Create Form Object
Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
// Open Document
pdfForm.BindPdf(dataDir + "FormField.pdf");
// Get button option values
string optionValue = pdfForm.GetButtonOptionCurrentValue("Gender");
Console.WriteLine("Current Value : {0} ", optionValue);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
// Open Document
pdfForm.BindPdf(dataDir + "input.pdf");
// Get field value
Console.WriteLine("Field Value : {0} ", pdfForm.GetField("textfield"));
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
// Create Form Object
Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
// Open Document
pdfForm.BindPdf(dataDir + "FormField.pdf");
// Get form field facade
FormFieldFacade fieldFacade = pdfForm.GetFieldFacade("textfield");
// Get facade values
Console.WriteLine("Alignment : {0} ", fieldFacade.Alignment);
Console.WriteLine("Background Color : {0} ", fieldFacade.BackgroundColor);
Console.WriteLine("Border Color : {0} ", fieldFacade.BorderColor);
Console.WriteLine("Border Style : {0} ", fieldFacade.BorderStyle);
Console.WriteLine("Border Width : {0} ", fieldFacade.BorderWidth);
Console.WriteLine("Box : {0} ", fieldFacade.Box);
Console.WriteLine("Caption : {0} ", fieldFacade.Caption);
Console.WriteLine("Font Name : {0} ", fieldFacade.Font);
Console.WriteLine("Font Size : {0} ", fieldFacade.FontSize);
Console.WriteLine("Page Number : {0} ", fieldFacade.PageNumber);
Console.WriteLine("Text Color : {0} ", fieldFacade.TextColor);
Console.WriteLine("Text Encoding : {0} ", fieldFacade.TextEncoding);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
// Open Document
form.BindPdf(dataDir + "input.pdf");
// Open fdf file.
System.IO.FileStream fdfInputStream = new FileStream(dataDir + "student.fdf", FileMode.Open);
// Import data
form.ImportFdf(fdfInputStream);
// Close file stream
fdfInputStream.Close();
// Save updated document
form.Save(dataDir + "ImportDataFromPdf_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
// Open Document
form.BindPdf(dataDir + "input.pdf");
// Open xfdf file.
System.IO.FileStream xfdfInputStream = new FileStream("student1.xfdf", FileMode.Open);
// Import data
form.ImportXfdf(xfdfInputStream);
// Close file stream
xfdfInputStream.Close();
// Save updated document
form.Save(dataDir + "ImportDataFromXFDF_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
// Open document
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
// Open xml file.
System.IO.FileStream xmlInputStream = new FileStream(dataDir + "input.xml", FileMode.Open);
// Import data
form.ImportXml(xmlInputStream);
// Close file stream
xmlInputStream.Close();
// Save updated document
form.Save(dataDir + "ImportDataFromXML_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
FormEditor formEditor = new FormEditor();
// Open Document
formEditor.BindPdf(dataDir + "input.pdf");
// Move field to new location
formEditor.MoveField("textfield", 300, 300, 400, 400);
// Save updated file
formEditor.Save( dataDir + "MoveFormField_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
FormEditor form = new FormEditor();
// Open the document and create a FormEditor object
form.BindPdf(dataDir + "input.pdf");
// Set JavaScript
form.SetFieldScript("pushbutton", "app.alert('Hello World!');");
// Save update document
form.Save(dataDir + "SetJSPushButton_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();
FormEditor form = new FormEditor();
// Open the document and create a FormEditor object
form.BindPdf(dataDir + "input.pdf");
// Set submit URL
form.SetSubmitUrl("submitbutton", "http:// Www.aspose.com");
// Save update document
form.Save(dataDir + "SetSubmitButtonURL_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Open document
PdfFileMend mender = new PdfFileMend();
// Create PdfFileMend object to add text
mender.BindPdf(dataDir + "AddImage.pdf");
// Add image in the PDF file
mender.AddImage(dataDir+ "aspose-logo.jpg", 1, 100, 600, 200, 700);
// Save changes
mender.Save(dataDir + "AddImage_out.pdf");
// Close PdfFileMend object
mender.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Instantiate PdfPageEditor class to get particular page region
Aspose.Pdf.Facades.PdfPageEditor editor = new Aspose.Pdf.Facades.PdfPageEditor();
// Bind the source PDF file
editor.BindPdf(dataDir + "Convert-PageRegion.pdf");
// Move the origin of PDF file to particular point
editor.MovePosition(0, 700);
// Create a memory stream object
MemoryStream ms = new MemoryStream();
// Save the updated document to stream object
editor.Save(ms);
// Create PdfConverter object
PdfConverter objConverter = new PdfConverter();
// Bind input pdf file
objConverter.BindPdf(ms);
// Set StartPage and EndPage properties to the page number to
// You want to convert images from
objConverter.StartPage = 1;
objConverter.EndPage = 1;
// Counter
int page = 1;
// Initialize the converting process
objConverter.DoConvert();
// Check if pages exist and then convert to image one by one
while (objConverter.HasNextImage())
objConverter.GetNextImage(dataDir+ "Specific_Region-Image" + page++ + "_out.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
// Close the PdfConverter object
objConverter.Close();
// Close MemoryStream object holding the updated document
ms.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Create PdfConverter object
PdfConverter objConverter = new PdfConverter();
// Bind input pdf file
objConverter.BindPdf(dataDir+ "ConvertPDFPages.pdf");
// Initialize the converting process
objConverter.DoConvert();
objConverter.CoordinateType = PageCoordinateType.CropBox;
// Check if pages exist and then convert to image one by one
while (objConverter.HasNextImage())
objConverter.GetNextImage(dataDir+ DateTime.Now.Ticks.ToString() + "_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
// Close the PdfConverter object
objConverter.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Create PdfConverter object and bind input PDF file
PdfConverter pdfConverter = new PdfConverter();
// Bind the source PDF file
pdfConverter.BindPdf(dataDir+ "ConvertToTIFF-Settings.pdf");
// Start the conversion process
pdfConverter.DoConvert();
// Convert to TIFF image
pdfConverter.SaveAsTIFF(dataDir+ "output_out.tif");
// Close Converter object
pdfConverter.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Create PdfConverter object and bind input PDF file
PdfConverter pdfConverter = new PdfConverter();
// Create Resolution object with 300 as an argument
Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);
// Specify the resolution value for PdfConverter object
pdfConverter.Resolution = resolution;
// Bind the source PDF file
pdfConverter.BindPdf(dataDir+ "ConvertToTIFF-Settings.pdf");
// Start the conversion process
pdfConverter.DoConvert();
// Create TiffSettings object and set ColorDepth
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp;
// Convert to TIFF image
pdfConverter.SaveAsTIFF(dataDir+ "output_out.tif", 300, 300, tiffSettings);
// Close Converter object
pdfConverter.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Open PDF file
PdfContentEditor contentEditor = new PdfContentEditor();
contentEditor.BindPdf(dataDir+ "DeleteAllImages.pdf");
// Delete the images from the particular page
contentEditor.DeleteImage();
// Save output PDF
contentEditor.Save(dataDir+ "DeleteAllImages_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Open PDF file
PdfContentEditor contentEditor = new PdfContentEditor();
contentEditor.BindPdf(dataDir+ "DeleteImages-Page.pdf");
// Array of images to be deleted
int[] imageIndex = new int[] { 1 };
// Delete the images from the particular page
contentEditor.DeleteImage(2, imageIndex);
// Save output PDF
contentEditor.Save(dataDir+ "DeleteImages-Page_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Open input PDF
PdfExtractor extractor = new PdfExtractor();
extractor.BindPdf(dataDir+ "ExtractImageExtractionMode.pdf");
// Specify Image Extraction Mode
extractor.ExtractImageMode = ExtractImageMode.DefinedInResources;
// Extract Images based on Image Extraction Mode
extractor.ExtractImage();
// Get all the extracted images
while (extractor.HasNextImage())
{
extractor.GetNextImage(dataDir+ DateTime.Now.Ticks.ToString() + "_out.png" , System.Drawing.Imaging.ImageFormat.Png);
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Open input PDF
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(dataDir+ "ExtractImages.pdf");
// Extract all the images
pdfExtractor.ExtractImage();
// Get all the extracted images
while (pdfExtractor.HasNextImage())
pdfExtractor.GetNextImage(dataDir+ DateTime.Now.Ticks.ToString() + "_out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Open input PDF
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(dataDir+ "ExtractImages-Page.pdf");
// Set StartPage and EndPage properties to the page number to
// You want to extract images from
pdfExtractor.StartPage = 2;
pdfExtractor.EndPage = 2;
// Extract images
pdfExtractor.ExtractImage();
// Get extracted images
while (pdfExtractor.HasNextImage())
{
// Read image into memory stream
MemoryStream memoryStream = new MemoryStream();
pdfExtractor.GetNextImage(memoryStream);
// Write to disk, if you like, or use it otherwise.
FileStream fileStream = new
FileStream(dataDir+ DateTime.Now.Ticks.ToString() + "_out.jpg", FileMode.Create);
memoryStream.WriteTo(fileStream);
fileStream.Close();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Open input PDF
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(dataDir+ "ExtractImages-Stream.pdf");
// Extract images
pdfExtractor.ExtractImage();
// Get all the extracted images
while (pdfExtractor.HasNextImage())
{
// Read image into memory stream
MemoryStream memoryStream = new MemoryStream();
pdfExtractor.GetNextImage(memoryStream);
// Write to disk, if you like, or use it otherwise.
FileStream fileStream = new
FileStream(dataDir+ DateTime.Now.Ticks.ToString() + "_out.jpg", FileMode.Create);
memoryStream.WriteTo(fileStream);
fileStream.Close();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images();
// Open input PDF
PdfContentEditor pdfContentEditor = new PdfContentEditor();
pdfContentEditor.BindPdf(dataDir+ "ReplaceImage.pdf");
// Replace image on a particular page
pdfContentEditor.ReplaceImage(1, 1, dataDir+ "aspose-logo.jpg");
// Save output PDF
pdfContentEditor.Save(dataDir+ "ReplaceImage_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Array of files
string[] portFiles = new string[2];
portFiles[0] = dataDir + "input.pdf";
portFiles[1] = dataDir + "input2.pdf";
// Append file
pdfEditor.Append(dataDir + "input3.pdf", portFiles, 1, 1, dataDir + "AppendArrayOfFiles_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Input and output stream
FileStream inputStream = new FileStream( dataDir + "input.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "AppendArrayOfFilesUsingStream_out.pdf", FileMode.Create);
// Srray of streams
FileStream[] portStreams = new FileStream[2];
portStreams[0] = new FileStream( dataDir + "input2.pdf", FileMode.Open);
portStreams[1] = new FileStream(dataDir + "input3.pdf", FileMode.Open);
// Append file
pdfEditor.Append(inputStream, portStreams, 1, 1, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Append file
pdfEditor.Append(dataDir + "input.pdf", dataDir + "input2.pdf", 1, 1, dataDir + "AppendFiles_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream( dataDir + "input.pdf", FileMode.Open);
FileStream portStream = new FileStream(dataDir + "input2.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "AppendFilesUsingStreams_out.pdf", FileMode.Create);
// Append file
pdfEditor.Append(inputStream, portStream, 1, 1, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Array of files
string[] filesArray = new string[2];
filesArray[0] = dataDir + "input.pdf";
filesArray[1] = dataDir + "input2.pdf";
// Concatenate files
pdfEditor.Concatenate(filesArray, dataDir + "ConcatenateArrayOfFilesWithPath_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
Aspose.Pdf.Facades.PdfFileEditor pfe = new Aspose.Pdf.Facades.PdfFileEditor();
pfe.CorruptedFileAction = Aspose.Pdf.Facades.PdfFileEditor.ConcatenateCorruptedFileAction.ConcatenateIgnoringCorrupted;
pfe.Concatenate(new string[] { dataDir + "input.pdf", dataDir + "input2.pdf", dataDir + "input3.pdf" }, dataDir + "CorruptedFiles_out.pdf");
if (pfe.CorruptedItems.Length > 0)
{
Console.WriteLine("Corrupted documents:");
foreach (Aspose.Pdf.Facades.PdfFileEditor.CorruptedItem item in pfe.CorruptedItems)
{ Console.WriteLine(item.Index + " reason " + item.Exception.Message); }
}
else Console.WriteLine("No corrupted documents");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Array of files
string[] filesArray = new string[2];
filesArray[0] = dataDir + "input.pdf";
filesArray[1] = dataDir + "input2.pdf";
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Display the resultant concatenated PDF file in
pdfEditor.Concatenate(filesArray, dataDir + "RenderInBrowser_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Output stream
FileStream outputStream = new FileStream(dataDir + "ConcatenateArrayOfPdfUsingStreams_out.pdf", FileMode.Create);
// Array of streams
FileStream[] inputStreams = new FileStream[2];
inputStreams[0] = new FileStream(dataDir + "input.pdf", FileMode.Open);
inputStreams[1] = new FileStream(dataDir + "input2.pdf", FileMode.Open);
// Concatenate file
pdfEditor.Concatenate(inputStreams, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream1 = new FileStream( dataDir + "input.pdf", FileMode.Open);
FileStream inputStream2 = new FileStream( dataDir + "input2.pdf", FileMode.Open);
FileStream blankStream = new FileStream(dataDir + "blank.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "ConcatenateBlankPdfUsingStreams_out.pdf", FileMode.Create);
// Concatenate file
pdfEditor.Concatenate(inputStream1, inputStream2, blankStream, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Concatenate files
pdfEditor.Concatenate(dataDir + "input.pdf", dataDir + "input2.pdf", dataDir + "ConcatenateUsingPath_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
PdfFileEditor pfe = new PdfFileEditor();
string[] files = Directory.GetFiles(dataDir);
pfe.CopyOutlines = false;
pfe.Concatenate(files, dataDir + "CopyOutline_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
FileStream fileInputStream1 = new FileStream(dataDir + "input.pdf", FileMode.Open, FileAccess.Read);
FileStream fileInputStream2 = new FileStream(dataDir + "input2.pdf", FileMode.Open, FileAccess.Read);
FileStream fileOutputStream = new FileStream(dataDir + "ConcatenateTaggedFiles_out.pdf" , FileMode.Create, FileAccess.Write);
// Concatenate files
PdfFileEditor editor = new PdfFileEditor();
editor.CopyLogicalStructure = true;
bool success = editor.Concatenate(fileInputStream1, fileInputStream2, fileOutputStream);
Console.Out.WriteLine("Successful... " + success);
// Close the streams
fileOutputStream.Close();
fileInputStream1.Close();
fileInputStream2.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Output stream
FileStream outputStream = new FileStream( dataDir + "ConcatenateUsingStreams_out.pdf", FileMode.Create);
// Input streams
FileStream inputStream1 = new FileStream( dataDir + "input.pdf", FileMode.Open);
FileStream inputStream2 = new FileStream( dataDir + "input2.pdf", FileMode.Open);
// Concatenate file
pdfEditor.Concatenate(inputStream1, inputStream2, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Concatenate files
pdfEditor.Concatenate(dataDir + "input.pdf", dataDir + "input2.pdf", dataDir + "blank.pdf", dataDir + "ConcatenateWithBlankPdf_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Array of pages to delete
int[] pagesToDelete = new int[] { 1, 2};
// Delete pages
pdfEditor.Delete(dataDir + "input.pdf", pagesToDelete, dataDir + "DeletePagesUsingFilePath_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream( dataDir + "input.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "DeletePagesUsingStream_out.pdf", FileMode.Create);
// Array of pages to delete
int[] pagesToDelete = new int[] { 1, 3 };
// Delete pages
pdfEditor.Delete(inputStream, pagesToDelete, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
int[] pagesToExtract = new int[] { 1, 2 };
// Extract pages
pdfEditor.Extract(dataDir + "Extract.pdf", pagesToExtract, dataDir + "ExtractArrayOfPages_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream( dataDir + "MultiplePages.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "ExtractArrayOfPagesUsingStreams_out.pdf", FileMode.Create);
int[] pagesToExtract = new int[] { 1, 2};
// Extract pages
pdfEditor.Extract(inputStream, pagesToExtract, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Extract pages
pdfEditor.Extract(dataDir + "MultiplePages.pdf", 1, 3, dataDir + "ExtractPagesBetweenNumbers_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream(dataDir + "MultiplePages.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "ExtractPagesBetweenTwoNumbers_out.pdf", FileMode.Create);
// Extract pages
pdfEditor.Extract(inputStream, 1, 3, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
int[] pagesToInsert = new int[] { 2, 3 };
// Insert pages
pdfEditor.Insert(dataDir + "MultiplePages.pdf", 1, dataDir + "InsertPages.pdf", pagesToInsert, dataDir + "InsertArrayOfPages_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Insert pages
pdfEditor.Insert(dataDir + "MultiplePages.pdf", 1, dataDir + "InsertPages.pdf", 2, 5, dataDir + "InsertPagesBetweenNumbers_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream(dataDir + "MultiplePages.pdf", FileMode.Open);
FileStream portStream = new FileStream(dataDir + "InsertPages.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "InsertPagesBetweenNumbersUsingStreams_out.pdf", FileMode.Create);
// Insert pages
pdfEditor.Insert(inputStream, 1, portStream, 1, 4, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream( dataDir + "MultiplePages.pdf", FileMode.Open);
FileStream portStream = new FileStream(dataDir + "InsertPages.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "InsertPagesUsingStreams_out.pdf", FileMode.Create);
int[] pagesToInsert = new int[] { 2, 3 };
// Insert pages
pdfEditor.Insert(inputStream, 1, portStream, pagesToInsert, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Set left and right pages
int[] leftPages = new int[] { 1, 5};
int[] rightPages = new int[] { 2, 3 };
// Make booklet
pdfEditor.MakeBooklet(dataDir + "MultiplePages.pdf", dataDir + "MakeBookletUsingLeftRightPagesAndPaths_out.pdf", leftPages, rightPages);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream(dataDir + "MultiplePages.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "MakeBookletUsingLeftRightPagesAndStreams_out.pdf", FileMode.Create);
// Set left and right pages
int[] leftPages = new int[] { 1, 5};
int[] rightPages = new int[] { 2, 3 };
// Make booklet
pdfEditor.MakeBooklet(inputStream, outputStream, leftPages, rightPages);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Make booklet
pdfEditor.MakeBooklet(dataDir + "input.pdf", dataDir + "MakeBookletUsingPageSizeAndPaths_out.pdf", PageSize.A5);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream(dataDir + "input.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "MakeBookletUsingPageSizeAndStreams_out.pdf", FileMode.Create);
// Make booklet
pdfEditor.MakeBooklet(inputStream, outputStream, PageSize.A5);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Set left and right pages
int[] leftPages = new int[] { 1, 5};
int[] rightPages = new int[] { 2, 3 };
// Make booklet
pdfEditor.MakeBooklet(dataDir + "MultiplePages.pdf", dataDir + "MakeBookletUsingPageSizeLeftRightPagesAndPaths_out.pdf", PageSize.A5, leftPages, rightPages);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream(dataDir + "MultiplePages.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "MakeBookletUsingPageSizeLeftRightPagesAndStreams_out.pdf", FileMode.Create);
// Set left and right pages
int[] leftPages = new int[] { 1, 5};
int[] rightPages = new int[] { 2, 3 };
// Make booklet
pdfEditor.MakeBooklet(inputStream, outputStream, PageSize.A5, leftPages, rightPages);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Make booklet
pdfEditor.MakeBooklet(dataDir + "input.pdf", dataDir + "MakeBookletUsingPaths_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream( dataDir + "input.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "MakeBookletUsingStreams_out.pdf", FileMode.Create);
// Make booklet
pdfEditor.MakeBooklet(inputStream, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Make NUp
pdfEditor.MakeNUp(dataDir + "MultiplePages.pdf", dataDir + "MakeNUpUsingPageSizeAndPaths_out.pdf", 2, 3, PageSize.A5);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream(dataDir + "input.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "MakeNUpUsingPageSizeAndStreams_out.pdf", FileMode.Create);
// Make NUp
pdfEditor.MakeNUp(inputStream, outputStream, 2, 3, PageSize.A5);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Make NUp
pdfEditor.MakeNUp(dataDir + "input.pdf", dataDir + "input2.pdf", "MakeNUpUsingPaths_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream1 = new FileStream(dataDir + "input.pdf", FileMode.Open);
FileStream inputStream2 = new FileStream(dataDir + "input2.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "MakeNUpUsingStreams_out.pdf", FileMode.Create);
// Make NUp
pdfEditor.MakeNUp(inputStream1, inputStream2, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create array of files
string[] filesArray = new string[2];
filesArray[0] = dataDir + "input.pdf";
filesArray[1] = dataDir + "input2.pdf";
// Make NUp
pdfEditor.MakeNUp(filesArray, dataDir + "UsingArrayOfFilesAndPaths_out.pdf", true);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream[] fileStreams = new FileStream[2];
fileStreams[0] = new FileStream(dataDir + "input.pdf", FileMode.Open);
fileStreams[1] = new FileStream(dataDir + "input2.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "UsingArrayOfFilesAndStreams_out.pdf", FileMode.Create);
// Make NUp
pdfEditor.MakeNUp(fileStreams, outputStream, true);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Make NUp
pdfEditor.MakeNUp(dataDir + "input.pdf", "UsingPageSizeHorizontalAndVerticalValues_out.pdf", 2, 3);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream(dataDir + "input.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "UsingPageSizeHorizontalVerticalValuesAndStreams_out.pdf", FileMode.Create);
// Make NUp
pdfEditor.MakeNUp(inputStream, outputStream, 2, 3);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Open document
PdfPageEditor pageEditor = new PdfPageEditor();
pageEditor.BindPdf(dataDir + "input.pdf");
// Get page properties
Console.WriteLine(pageEditor.GetPageRotation(1));
Console.WriteLine(pageEditor.GetPages());
Console.WriteLine(pageEditor.GetPageBoxSize(1, "trim"));
Console.WriteLine(pageEditor.GetPageBoxSize(1, "art"));
Console.WriteLine(pageEditor.GetPageBoxSize(1, "bleed"));
Console.WriteLine(pageEditor.GetPageBoxSize(1, "crop"));
Console.WriteLine(pageEditor.GetPageBoxSize(1, "media"));
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor Object
PdfFileEditor fileEditor = new PdfFileEditor();
// Open PDF Document
Document doc = new Document(dataDir + "input.pdf");
// Specify Parameter to be used for resizing
PdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(
// Left margin = 10% of page width
PdfFileEditor.ContentsResizeValue.Percents(10),
// New contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
null,
// Right margin is 10% of page
PdfFileEditor.ContentsResizeValue.Percents(10),
// Top margin = 10% of height
PdfFileEditor.ContentsResizeValue.Percents(10),
// New contents height is calculated automatically (similar to width)
null,
// Bottom margin is 10%
PdfFileEditor.ContentsResizeValue.Percents(10)
);
// Resize Page Contents
fileEditor.ResizeContents(doc, new int[] { 1, 2 }, parameters);
// Save document into new location.
doc.Save(dataDir + "ResizePageContents_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Open document
PdfPageEditor pageEditor = new PdfPageEditor();
pageEditor.BindPdf(dataDir + "input.pdf");
// Set page properties
// Move origin from (0,0)
pageEditor.MovePosition(100, 100);
// Set page rotations
Hashtable pageRotations = new Hashtable();
pageRotations.Add(1, 90);
pageRotations.Add(2, 180);
pageRotations.Add(3, 270);
// PageEditor.PageRotations = pageRotations;
// Set zoom where 1.0f = 100% zoom
pageEditor.Zoom = 2.0f;
// Save updated PDF file
pageEditor.Save(dataDir + "SetPageProperties_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
int fileNumber = 1;
// Create array of pages to split
int[][] numberOfPages = new int[][] { new int[] { 1, 2 }, new int[] { 3, 4 } };
// Split to bulk
MemoryStream[] outBuffer = pdfEditor.SplitToBulks(dataDir + "MultiplePages.pdf", numberOfPages);
// Save individual files
foreach (MemoryStream aStream in outBuffer)
{
FileStream outStream = new FileStream(dataDir + "File_" + fileNumber.ToString() + "_out.pdf", FileMode.Create);
aStream.WriteTo(outStream);
outStream.Close();
fileNumber++;
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create input stream
FileStream inputStream = new FileStream(dataDir + "MultiplePages.pdf", FileMode.Open);
int fileNumber = 1;
// Create array of pages to split
int[][] numberOfPages = new int[][] { new int[] { 1, 2 }, new int[] { 3, 4} };
// Split to bulk
MemoryStream[] outBuffer = pdfEditor.SplitToBulks(inputStream, numberOfPages);
// Save individual files
foreach (MemoryStream aStream in outBuffer)
{
FileStream outStream = new FileStream(dataDir + "File_" + fileNumber.ToString() + "_out.pdf", FileMode.Create);
aStream.WriteTo(outStream);
outStream.Close();
fileNumber++;
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Split pages
pdfEditor.SplitToEnd(dataDir + "MultiplePages.pdf", 3, dataDir + "SplitPagesToEndUsingPaths_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream(dataDir + "MultiplePages.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "SplitPagesToEndUsingStreams_out.pdf", FileMode.Create);
// Split pages
pdfEditor.SplitToEnd(inputStream, 3, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Split pages
pdfEditor.SplitFromFirst(dataDir + "MultiplePages.pdf", 3, dataDir + "SplitPagesUsingPaths_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create streams
FileStream inputStream = new FileStream(dataDir + "MultiplePages.pdf", FileMode.Open);
FileStream outputStream = new FileStream(dataDir + "SplitPagesUsingStreams_out.pdf", FileMode.Create);
// Split pages
pdfEditor.SplitFromFirst(inputStream, 3, outputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
int fileNumber = 1;
// Split to pages
MemoryStream[] outBuffer = pdfEditor.SplitToPages(dataDir + "input.pdf");
// Save individual files
foreach (MemoryStream aStream in outBuffer)
{
FileStream outStream = new FileStream(dataDir + "File_" + fileNumber.ToString() + "_out.pdf", FileMode.Create);
aStream.WriteTo(outStream);
outStream.Close();
fileNumber++;
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Pages();
// Create PdfFileEdito object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create input stream
FileStream inputStream = new FileStream(dataDir + "input.pdf", FileMode.Open);
int fileNumber = 1;
// Split to pages
MemoryStream[] outBuffer = pdfEditor.SplitToPages(inputStream);
// Save individual files
foreach (MemoryStream aStream in outBuffer)
{
FileStream outStream = new FileStream(dataDir + "File_" + fileNumber.ToString() + "_out.pdf", FileMode.Create);
aStream.WriteTo(outStream);
outStream.Close();
fileNumber++;
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
// Instantiate PdfViewer object
PdfViewer viewer = new PdfViewer();
// Bind source PDF file
viewer.BindPdf(dataDir + "input.pdf");
viewer.AutoResize = true;
// Hide printing dialog
viewer.PrintPageDialog = false;
// Create Printer Settings object
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();
// Specify the printer anme
ps.PrinterName = "Microsoft XPS Document Writer";
// Resultant Printout name
ps.PrintFileName = "ResultantPrintout.xps";
// Print the output to file
ps.PrintToFile = true;
ps.FromPage = 1;
ps.ToPage = 2;
ps.PrintRange = System.Drawing.Printing.PrintRange.SomePages;
// Specify the page size of printout
pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
ps.DefaultPageSettings.PaperSize = pgs.PaperSize;
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
// Print the document with settings specified above
viewer.PrintDocumentWithSettings(pgs, ps);
// Check the print status
if (viewer.PrintStatus != null)
{
// An exception was thrown
Exception ex = viewer.PrintStatus as Exception;
if (ex != null)
{
// Get exception message
}
}
else
{
// No errors were found. Printing job has completed successfully
Console.WriteLine("printing completed without any issue..");
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
private static string GetCurrentUserCredentials()
{
// The implementation depends on type of running application (ASP.NET, Windows forms, etc.)
string userCredentials = string.Empty;
return userCredentials;
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
PdfViewer viewer = new PdfViewer();
// Bind source PDF file
viewer.BindPdf(dataDir + "input.pdf");
// Specify the name of Print job
viewer.PrinterJobName = GetCurrentUserCredentials();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
PdfViewer viewer = new PdfViewer();
viewer.BindPdf( dataDir + "input.pdf");
viewer.PrintPageDialog = false;
// Do not produce the page number dialog when printing
using (new Impersonator("OwnerUserName", "SomeDomain", "OwnerUserNamePassword"))
{
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
ps.PrinterName = "Microsoft XPS Document Writer";
viewer.PrintDocumentWithSettings(ps); // OwnerUserName is a value of Owner column in spooler app
viewer.Close();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
Aspose.Pdf.Facades.PdfViewer viewer = new Aspose.Pdf.Facades.PdfViewer();
viewer.BindPdf(dataDir + "input.pdf");
// Set PrinterSettings and PageSettings
System.Drawing.Printing.PrinterSettings printerSetttings = new System.Drawing.Printing.PrinterSettings();
printerSetttings.Copies = 1;
// Set PS printer, one can find this driver in the list of preinstalled printer drivers in Windows
printerSetttings.PrinterName = "HP LaserJet 2300 Series PS";
// Set output file name and PrintToFile attribute
printerSetttings.PrintFileName = dataDir + "PdfToPostScript_out.ps";
printerSetttings.PrintToFile = true;
// Disable print page dialog
viewer.PrintPageDialog = false;
// Pass printer settings object to the method
viewer.PrintDocumentWithSettings(printerSetttings);
viewer.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// Render all system fonts with native system approach (embed the fonts to output documents)
viewer.RenderingOptions.SystemFontsNativeRendering = true;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
// Create PdfViewer object and bind PDF file
PdfViewer pdfViewer = new PdfViewer();
pdfViewer.BindPdf( dataDir + "input.pdf");
// Set PrinterSettings and PageSettings
System.Drawing.Printing.PrinterSettings printerSetttings = new System.Drawing.Printing.PrinterSettings();
printerSetttings.Copies = 1;
printerSetttings.PrinterName = "Microsoft XPS Document Writer";
// Set output file name and PrintToFile attribute
printerSetttings.PrintFileName = dataDir + "print_out.xps";
printerSetttings.PrintToFile = true;
// Disable print page dialog
pdfViewer.PrintPageDialog = false;
// Pass printer settings object to the method
pdfViewer.PrintDocumentWithSettings(printerSetttings);
pdfViewer.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
// Create PdfViewer object
PdfViewer viewer = new PdfViewer();
// Open input PDF file
viewer.BindPdf( dataDir + "input.pdf");
// Set attributes for printing
viewer.AutoResize = true; // Print the file with adjusted size
viewer.AutoRotate = true; // Print the file with adjusted rotation
viewer.PrintPageDialog = false; // Do not produce the page number dialog when printing
// Create objects for printer and page settings and PrintDocument
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
// Set XPS/PDF printer name
ps.PrinterName = "Microsoft XPS Document Writer";
// Or set the PDF printer
// Ps.PrinterName = "Adobe PDF";
// Set PageSize (if required)
pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
// Set PageMargins (if required)
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
// Print document using printer and page settings
viewer.PrintDocumentWithSettings(pgs, ps);
// Close the PDF file after priting
viewer.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
private static void PdfvOnPdfQueryPageSettings(object sender, System.Drawing.Printing.QueryPageSettingsEventArgs queryPageSettingsEventArgs, PdfPrintPageInfo currentPageInfo)
{
bool isOdd = currentPageInfo.PageNumber % 2 != 0;
System.Drawing.Printing.PrinterSettings.PaperSourceCollection paperSources = queryPageSettingsEventArgs.PageSettings.PrinterSettings.PaperSources;
if (isOdd)
queryPageSettingsEventArgs.PageSettings.PaperSource = paperSources[0];
else
queryPageSettingsEventArgs.PageSettings.PaperSource = paperSources[1];
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
Aspose.Pdf.Facades.PdfViewer pdfv = new Aspose.Pdf.Facades.PdfViewer();
pdfv.PdfQueryPageSettings += PdfvOnPdfQueryPageSettings;
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
System.Drawing.Printing.PrinterSettings prin = new System.Drawing.Printing.PrinterSettings();
pdfv.BindPdf(dataDir + "Print-PageRange.pdf");
prin.PrinterName = "HP LaserJet M9050 MFP PCL6";
prin.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
Aspose.Pdf.Facades.PdfPageEditor pageEditor = new Aspose.Pdf.Facades.PdfPageEditor();
pageEditor.BindPdf(dataDir + "input.pdf");
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
pgs.PaperSize = prin.DefaultPageSettings.PaperSize;
pdfv.PrintDocumentWithSettings(pgs, prin);
pdfv.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
struct PrintingJobSettings
{
public int ToPage { get; set; }
public int FromPage { get; set; }
public string OutputFile { get; set; }
public System.Drawing.Printing.Duplex Mode { get; set; }
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
int printingJobIndex = 0;
string inPdf = dataDir + "input.pdf";
string output = dataDir;
IList<PrintingJobSettings> printingJobs = new List<PrintingJobSettings>();
PrintingJobSettings printingJob1 = new PrintingJobSettings();
printingJob1.FromPage = 1;
printingJob1.ToPage = 3;
printingJob1.OutputFile = output + "35925_1_3.xps";
printingJob1.Mode = Duplex.Default;
printingJobs.Add(printingJob1);
PrintingJobSettings printingJob2 = new PrintingJobSettings();
printingJob2.FromPage = 4;
printingJob2.ToPage = 6;
printingJob2.OutputFile = output + "35925_4_6.xps";
printingJob2.Mode = Duplex.Simplex;
printingJobs.Add(printingJob2);
PrintingJobSettings printingJob3 = new PrintingJobSettings();
printingJob3.FromPage = 7;
printingJob3.ToPage = 7;
printingJob3.OutputFile = output + "35925_7.xps";
printingJob3.Mode = Duplex.Default;
printingJobs.Add(printingJob3);
PdfViewer viewer = new PdfViewer();
viewer.BindPdf(inPdf);
viewer.AutoResize = true;
viewer.AutoRotate = true;
viewer.PrintPageDialog = false;
PrinterSettings ps = new PrinterSettings();
PageSettings pgs = new PageSettings();
ps.PrinterName = "Microsoft XPS Document Writer";
ps.PrintFileName = Path.GetFullPath(printingJobs[printingJobIndex].OutputFile);
ps.PrintToFile = true;
ps.FromPage = printingJobs[printingJobIndex].FromPage;
ps.ToPage = printingJobs[printingJobIndex].ToPage;
ps.Duplex = printingJobs[printingJobIndex].Mode;
ps.PrintRange = PrintRange.SomePages;
pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
ps.DefaultPageSettings.PaperSize = pgs.PaperSize;
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
viewer.EndPrint += (sender, args) =>
{
if (++printingJobIndex < printingJobs.Count)
{
ps.PrintFileName = Path.GetFullPath(printingJobs[printingJobIndex].OutputFile);
ps.FromPage = printingJobs[printingJobIndex].FromPage;
ps.ToPage = printingJobs[printingJobIndex].ToPage;
ps.Duplex = printingJobs[printingJobIndex].Mode;
viewer.PrintDocumentWithSettings(pgs, ps);
}
};
viewer.PrintDocumentWithSettings(pgs, ps);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
if (printDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
// Document printing code goes here
// Print document using printer and page settings
viewer.PrintDocumentWithSettings(pgs, ps);
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
// Create PdfViewer object
PdfViewer viewer = new PdfViewer();
// Open input PDF file
viewer.BindPdf( dataDir + "input.pdf");
// Set attributes for printing
viewer.AutoResize = true; // Print the file with adjusted size
viewer.AutoRotate = true; // Print the file with adjusted rotation
viewer.PrintPageDialog = false; // Do not produce the page number dialog when printing
// Create objects for printer and page settings and PrintDocument
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();
// Set printer name
ps.PrinterName = prtdoc.PrinterSettings.PrinterName;
// Set PageSize (if required)
pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
// Set PageMargins (if required)
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
// Print document using printer and page settings
viewer.PrintDocumentWithSettings(pgs, ps);
// Close the PDF file after priting
viewer.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
// Create PdfFileSecurity object
PdfFileSecurity fileSecurity = new PdfFileSecurity();
fileSecurity.BindPdf(dataDir + "ChangePassword.pdf");
// Change password
fileSecurity.ChangePassword("owner", "newuserpassword", "newownerpassword");
fileSecurity.Save(dataDir + "ChangeFilePassword_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
// Create PdfFileSecurity object
PdfFileSecurity fileSecurity = new PdfFileSecurity();
fileSecurity.BindPdf(dataDir + "Decrypt.pdf");
// Decrypt PDF document
fileSecurity.DecryptFile("owner");
fileSecurity.Save(dataDir + "DecryptFile_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
string pbxFile = "";
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
// Create PdfFileSignature object and bind input and output PDF files
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.BindPdf(dataDir + "DigitallySign.pdf");
// Create a rectangle for signature location
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100);
// Set signature appearance
pdfSign.SignatureAppearance = dataDir + "aspose-logo.jpg";
// Create any of the three signature types
PKCS1 signature = new PKCS1(pbxFile, "password"); // PKCS#1 or
pdfSign.Sign(1, "Signature Reason", "Contact", "Location", true, rect, signature);
// Save output PDF file
pdfSign.Save(dataDir + "DigitallySignature_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
// Create PdfFileSecurity object
PdfFileSecurity fileSecurity = new PdfFileSecurity();
fileSecurity.BindPdf(dataDir + "Encrypt.pdf");
// Encrypt file using 256-bit encryption
fileSecurity.EncryptFile("user", "owner", DocumentPrivilege.Print, KeySize.x256, Algorithm.AES);
fileSecurity.Save(dataDir + "Encrypt_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
string input = dataDir + "DigitallySign.pdf";
Document doc = new Document(input);
using (PdfFileSignature signature = new PdfFileSignature(doc))
{
if (signature.ContainsSignature())
{
foreach (string sigName in signature.GetSignNames())
{
string outFile = dataDir + "ExtractImages_out.jpg";
using (Stream imageStream = signature.ExtractImage(sigName))
{
if (imageStream != null)
{
using (System.Drawing.Image image = Bitmap.FromStream(imageStream))
{
image.Save(outFile, ImageFormat.Jpeg);
}
}
}
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
string input = dataDir + "DigitallySign.pdf";
string pkcs1File = "";
using (PdfFileSignature pdfFileSignature = new PdfFileSignature())
{
pdfFileSignature.BindPdf(input);
IList sigNames = pdfFileSignature.GetSignNames();
if (sigNames.Count > 0)
{
string sigName = sigNames[0] as string;
if (string.IsNullOrEmpty(sigName))
{
Stream cerStream = pdfFileSignature.ExtractCertificate(sigName);
if (cerStream != null)
{
using (cerStream)
{
byte[] bytes = new byte[cerStream.Length];
using (FileStream fs = new FileStream(dataDir + pkcs1File, FileMode.CreateNew))
{
cerStream.Read(bytes, 0, bytes.Length);
fs.Write(bytes, 0, bytes.Length);
}
}
}
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
string input = dataDir + "DigitallySign.pdf";
using (PdfFileSignature pdfSign = new PdfFileSignature())
{
pdfSign.BindPdf(input);
if (pdfSign.ContainsUsageRights())
{
pdfSign.RemoveUsageRights();
}
pdfSign.Document.Save(dataDir + "RemoveRights_out.pdf");
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
// Create PdfFileSignature object
PdfFileSignature pdfSign = new PdfFileSignature();
// Open PDF document
pdfSign.BindPdf(dataDir + "DigitallySign.pdf");
// Get list of signature names
IList names = pdfSign.GetSignNames();
// Remove all the signatures from the PDF file
for (int index = 0; index < names.Count; index++)
{
pdfSign.RemoveSignature((string)names[index]);
}
// Save updated PDF file
pdfSign.Save(dataDir + "RemoveSignature_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
new License().SetLicense(@"E:\Aspose.Pdf.lic");
string inSingleSignedFile = @"C:\pdftest\PDFNEWNET_34561_SingleSigned.pdf";
string outSingleUnsignedFile = @"C:\pdftest\PDFNEWNET_34561_SingleUnSigned.pdf";
string inOutSingleResignedFile = @"C:\pdftest\PDFNEWNET_34561_SingleReSigned.pdf";
PdfFileSignature pdfSignSingle = new PdfFileSignature();
pdfSignSingle.BindPdf(inSingleSignedFile);
IList names = pdfSignSingle.GetSignNames();
Stream pfx = new FileStream(@"C:\pdftest\test1.pfx", FileMode.Open);
PKCS7 pcks = new PKCS7(pfx, "test1");
string sigNameSingle = names[0] as string;
if (sigNameSingle != null && sigNameSingle != string.Empty)
{
pdfSignSingle.RemoveSignature(sigNameSingle, false);
pdfSignSingle.Save(outSingleUnsignedFile);
PdfFileSignature pdfSignSingle2 = new PdfFileSignature();
pdfSignSingle2.BindPdf(outSingleUnsignedFile);
pdfSignSingle2.SignatureAppearance = @"C:\pdftest\butterfly.jpg";
pdfSignSingle2.Sign("Signature1", pcks);
pdfSignSingle2.Save(inOutSingleResignedFile);
pdfSignSingle2.BindPdf(inOutSingleResignedFile);
// Assert.True(pdfSignSingle2.VerifySignature("Signature1"));
Console.Write("Signature 1 check result : " + pdfSignSingle2.VerifySignature("Signature1").ToString() + " \n");
}
// Test file with multiple signatures
string outManyUnsignedFile = @"C:\pdftest\PDFNEWNET_34561_ManyUnSigned.pdf";
string inOutManyResignedFile = @"C:\pdftest\PDFNEWNET_34561_ManyReSigned.pdf";
PdfFileSignature pdfSignMany = new Aspose.Pdf.Facades.PdfFileSignature();
IList sigNames = pdfSignMany.GetSignNames();
foreach (string sigName in sigNames)
{
pdfSignMany.RemoveSignature(sigName, false);
}
pdfSignMany.Save(outManyUnsignedFile);
PdfFileSignature pdfSignMany2 = new PdfFileSignature();
pdfSignMany2.BindPdf(outManyUnsignedFile);
pdfSignMany2.Sign("Signature1", pcks);
pdfSignMany2.Save(inOutManyResignedFile);
pdfSignMany2.BindPdf(inOutSingleResignedFile);
// Assert.IsTrue(pdfSignMany2.VerifySignature("Signature1"));
Console.Write("Signature 2 check result : " + pdfSignMany2.VerifySignature("Signature1").ToString() + " ");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
// Create DocumentPrivileges object
DocumentPrivilege privilege = DocumentPrivilege.ForbidAll;
privilege.ChangeAllowLevel = 1;
privilege.AllowPrint = true;
privilege.AllowCopy = true;
// Create PdfFileSecurity object
PdfFileSecurity fileSecurity = new PdfFileSecurity();
fileSecurity.BindPdf(dataDir + "input.pdf");
// Set document privileges
fileSecurity.SetPrivilege(privilege);
fileSecurity.Save(dataDir + "SetPrivilegesOnFile_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.BindPdf(dataDir + "DigitallySign.pdf");
pdfSign.ContainsSignature();
// Any signatures?
pdfSign.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.BindPdf(dataDir + "DigitallySign.pdf");
if (pdfSign.VerifySigned("Signature1"))
{
Console.WriteLine("PDF Signed");
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.BindPdf(dataDir + "DigitallySign.pdf");
if (pdfSign.VerifySignature("Signature1"))
{
Console.WriteLine("Signature Verified");
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddFooter.pdf");
// Create formatted text for page number
FormattedText formattedText = new FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);
// Add footer
fileStamp.AddFooter(formattedText, 10);
// Save updated PDF file
fileStamp.Save(dataDir + "AddFooter_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddHeader.pdf");
// Create formatted text for page number
FormattedText formattedText = new FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);
// Add header
fileStamp.AddHeader(formattedText, 10);
// Save updated PDF file
fileStamp.Save(dataDir + "AddHeader_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddImage-Footer.pdf");
// Add footer
fileStamp.AddFooter(new FileStream(dataDir+ "aspose-logo.jpg", FileMode.Open), 10);
// Save updated PDF file
fileStamp.Save(dataDir + "AddImage-Footer_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddImage-Header.pdf");
// Add Header
fileStamp.AddHeader(new FileStream(dataDir + "AddImageHeader.jpg", FileMode.Open), 10);
// Save updated PDF file
fileStamp.Save(dataDir + "AddImage-Header_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddImageStampAll.pdf");
// Create stamp
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindImage(dataDir+ "aspose-logo.jpg");
stamp.SetOrigin(200, 200);
stamp.Rotation = 90.0F;
stamp.IsBackground = true;
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
// Save updated PDF file
fileStamp.Save(dataDir + "AddImageStampAll_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddImageStamp-Page.pdf");
// Create stamp
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindImage(dataDir+ "aspose-logo.jpg");
stamp.SetOrigin(200, 200);
stamp.Rotation = 90.0F;
stamp.IsBackground = true;
// Set particular pages
stamp.Pages = new int[] { 1 };
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
// Save updated PDF file
fileStamp.Save(dataDir + "AddImageStamp-Page_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddPageNumber.pdf");
// Get total number of pages
int totalPages = new PdfFileInfo(dataDir + "AddPageNumber.pdf").NumberOfPages;
// Create formatted text for page number
FormattedText formattedText = new FormattedText("Page # Of " + totalPages, System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);
// Set starting number for first page; you might want to start from 2 or more
fileStamp.StartingNumber = 1;
// Add page number
fileStamp.AddPageNumber(formattedText, 0);
// Save updated PDF file
fileStamp.Save(dataDir + "AddPageNumber_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddPageNumber.pdf");
// Specify numbering style as Numerals Roman UpperCase
fileStamp.NumberingStyle = NumberingStyle.NumeralsRomanUppercase;
// Add page number stamp at Bottom-Center of page
fileStamp.AddPageNumber("#");
// Save updated PDF file
fileStamp.Save(dataDir + "CustomNumberStyle_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddPageStampAll.pdf");
// Create stamp
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindPdf(dataDir+ "temp.pdf", 1);
stamp.SetOrigin(200, 200);
stamp.Rotation = 90.0F;
stamp.IsBackground = true;
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
// Save updated PDF file
fileStamp.Save(dataDir + "AddPageStampAll_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddPageStamp-Page.pdf");
// Create stamp
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindPdf(dataDir+ "temp.pdf", 1);
stamp.SetOrigin(200, 200);
stamp.Rotation = 90.0F;
stamp.IsBackground = true;
// Set particular pages
stamp.Pages = new int[] { 2 };
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
// Save updated PDF file
fileStamp.Save(dataDir + "AddPageStamp-Page_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddTextStampAll.pdf");
// Create stamp
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindLogo(new FormattedText("Hello World!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 14));
stamp.SetOrigin(200, 200);
stamp.Rotation = 90.0F;
stamp.IsBackground = true;
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
// Save updated PDF file
fileStamp.Save(dataDir + "AddTextStampAll_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "AddTextStamp-Page.pdf");
// Create stamp
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindLogo(new FormattedText("Hello World!", System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 14));
stamp.SetOrigin(200, 200);
stamp.Rotation = 90.0F;
stamp.IsBackground = true;
// Set particular pages
stamp.Pages = new int[] { 1};
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
// Save updated PDF file
fileStamp.Save(dataDir + "AddTextStamp-Page_out.pdf");
// Close fileStamp
fileStamp.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Instantiate PdfContentEditor Object
PdfContentEditor pdfContentEditor = new PdfContentEditor();
// Bind input PDF file
pdfContentEditor.BindPdf(dataDir + "ChangeStampPosition.pdf");
int pageId = 1;
int stampIndex = 1;
double x = 200;
double y = 200;
// Change the position of the stamp to new x and y position
pdfContentEditor.MoveStamp(pageId, stampIndex, x, y);
// Save the Pdf file
pdfContentEditor.Save(dataDir + "ChangeStampPosition_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Instantiate PdfContentEditor Object
PdfContentEditor pdfContentEditor = new PdfContentEditor();
// Bind input PDF file
pdfContentEditor.BindPdf(dataDir + "ChangeStampPosition.pdf");
int pageId = 1;
int stampId = 1;
double x = 200;
double y = 200;
// Change the position of the stamp to new x and y position
pdfContentEditor.MoveStamp(pageId, stampId, x, y);
// Save the Pdf file
pdfContentEditor.Save(dataDir + "ChangeStampPositionByID_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_StampsWatermarks();
// Instantiate PdfContentEditor Object
PdfContentEditor pdfContentEditor = new PdfContentEditor();
// Bind input PDF file
pdfContentEditor.BindPdf(dataDir + "ExtractImage-ImageStamp.pdf");
// Get Stamp info for the first stamp
StampInfo[] infos = pdfContentEditor.GetStamps(1);
// Get the image from Stamp Info
System.Drawing.Image image = infos[0].Image;
// Save the extracted image
image.Save(dataDir + "image_out.jpg");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Specify input and output PDF file paths
string inputFile = dataDir + "inFile.pdf";
string outputFile = dataDir + "AddTextImagesUsingPdfFileMend_out.pdf";
// Specify image file path
string imageName = dataDir + "aspose-logo.jpg";
// Create file streams for all of the files to be used in the example
FileStream inImgStream = new FileStream(@imageName, FileMode.Open);
FileStream outputStream = new FileStream(@outputFile, FileMode.Create);
Document doc = new Document(inputFile);
// Create instance of PdfFileMend class
PdfFileMend mendor = new PdfFileMend(doc);
// Add image to the input PDF file on page number 1 at specified location
mendor.AddImage(inImgStream, 1, 50, 50, 100, 100);
// Create new FormattedText type object to add text in the PDF file
FormattedText ft = new FormattedText(
"PdfFileMend testing! 0 rotation.",
System.Drawing.Color.FromArgb(0, 200, 0),
FontStyle.TimesRoman,
EncodingType.Winansi,
false,
12);
// Add text in the existing PDF file
mendor.AddText(ft, 1, 50, 100, 100, 200);
// Claose the PdfFileMend type object
mendor.Close();
// Close output file stream
outputStream.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create an object of PdfAnnotationEditor class
PdfAnnotationEditor editor = new PdfAnnotationEditor();
// Bind input PDF file
editor.BindPdf(dataDir + "inFile.pdf");
// Create a file stream for output XFDF file to export annotations
FileStream fileStream = new FileStream(dataDir + "exportannotations.xfdf", FileMode.Create, FileAccess.Write);
// Create an enumeration of all the annotation types which you want to export
Enum[] annoType = { AnnotationType.Text };
// Export annotations of specified type(s) to XFDF file
editor.ExportAnnotationsXfdf(fileStream, 1, 5, annoType);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create an object of PdfAnnotationEditor class
PdfAnnotationEditor editor = new PdfAnnotationEditor();
// Bind input PDF file
editor.BindPdf(dataDir + "inFile.pdf");
// Create a file stream for input XFDF file to import annotations
FileStream fileStream = new FileStream(dataDir + "exportannotations.xfdf", FileMode.Open, FileAccess.Read);
// Create an enumeration of all the annotation types which you want to import
Enum[] annType = { AnnotationType.Text };
// Import annotations of specified type(s) from XFDF file
editor.ImportAnnotationFromXfdf(fileStream, annType);
// Save output pdf file
editor.Save(dataDir + "ImportAnnotations_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create PdfPageEditor object
PdfPageEditor pEdit = new PdfPageEditor();
// Bind pdf file
pEdit.BindPdf(dataDir + "FilledForm.pdf");
// Change page size of the selected pages
pEdit.ProcessPages = new int[] { 1};
// Here we select a member named 'LETTER' from the list of members of PageSize class and assign it to PageSize property of the PdfPageEditor class
pEdit.PageSize = PageSize.PageLetter;
// Save the file
pEdit.Save(dataDir + "ChangePageSizes_out.pdf");
// Find at what size a page has been assigned
pEdit.BindPdf(dataDir + "FilledForm.pdf");
PageSize size = pEdit.GetPageSize(1);
pEdit = null;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
Document doc = new Document(dataDir + "FilledForm.pdf");
// Open the document and create a Form object
FormEditor formEditor = new FormEditor(doc);
// Add a text field
formEditor.AddField(FieldType.Text, "text1", 1, 200, 550, 300, 575);
// Set field attribute - PropertyFlag enumeration contains 4 options
formEditor.SetFieldAttribute("text1", PropertyFlag.Required);
// Set field limit - this field will take maximum 20 characters as input
formEditor.SetFieldLimit("text1", 20);
// Close the document
formEditor.Save(dataDir + "ChangingFieldAppearance_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create two file streams to read pdf files
FileStream fs1 = new FileStream(dataDir + "inFile.pdf", FileMode.Open, FileAccess.Read);
FileStream fs2 = new FileStream(dataDir + "inFile2.pdf", FileMode.Open, FileAccess.Read);
// Create byte arrays to keep the contents of PDF files
byte[] buffer1 = new byte[Convert.ToInt32(fs1.Length)];
byte[] buffer2 = new byte[Convert.ToInt32(fs2.Length)];
int i = 0;
// Read PDF file contents into byte arrays
i = fs1.Read(buffer1, 0, Convert.ToInt32(fs1.Length));
i = fs2.Read(buffer2, 0, Convert.ToInt32(fs2.Length));
// Now, first convert byte arrays into MemoryStreams and then concatenate those streams
using (MemoryStream pdfStream = new MemoryStream())
{
using (MemoryStream fileStream1 = new MemoryStream(buffer1))
{
using (MemoryStream fileStream2 = new MemoryStream(buffer2))
{
// Create instance of PdfFileEditor class to concatenate streams
PdfFileEditor pdfEditor = new PdfFileEditor();
// Concatenate both input MemoryStreams and save to putput MemoryStream
pdfEditor.Concatenate(fileStream1, fileStream2, pdfStream);
// Convert MemoryStream back to byte array
byte[] data = pdfStream.ToArray();
// Create a FileStream to save the output PDF file
FileStream output = new FileStream(dataDir + "merged_out.pdf", FileMode.Create,
FileAccess.Write);
// Write byte array contents in the output file stream
output.Write(data, 0, data.Length);
// Close output file
output.Close();
}
}
}
// Close input files
fs1.Close();
fs2.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Set Text Stamp to display string Table Of Contents
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindLogo(new FormattedText("Table Of Contents", System.Drawing.Color.Maroon, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 18));
// Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
stamp.SetOrigin((new PdfFileInfo(new FileStream(dataDir + "input1.pdf", FileMode.Open)).GetPageWidth(1) / 3), 700);
// Set particular pages
stamp.Pages = new int[] { 1 };
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Create a MemoryStream object to hold the resultant PDf file
using (MemoryStream Concatenated_Stream = new MemoryStream())
{
// Save concatenated output file
pdfEditor.Concatenate(new FileStream(dataDir + "input1.pdf", FileMode.Open), new FileStream(dataDir + "input2.pdf", FileMode.Open), Concatenated_Stream);
// Insert a blank page at the begining of concatenated file to display Table of Contents
Aspose.Pdf.Document concatenated_pdfDocument = new Aspose.Pdf.Document(Concatenated_Stream);
// Insert a empty page in a PDF
concatenated_pdfDocument.Pages.Insert(1);
// Hold the resultnat file with empty page added
using (MemoryStream Document_With_BlankPage = new MemoryStream())
{
// Save output file
concatenated_pdfDocument.Save(Document_With_BlankPage);
using (var Document_with_TOC_Heading = new MemoryStream())
{
// Add Table Of Contents logo as stamp to PDF file
PdfFileStamp fileStamp = new PdfFileStamp();
// Find the input file
fileStamp.BindPdf(Document_With_BlankPage);
// Set Text Stamp to display string Table Of Contents
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindLogo(new FormattedText("Table Of Contents", System.Drawing.Color.Maroon, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 18));
// Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
stamp.SetOrigin((new PdfFileInfo(Document_With_BlankPage).GetPageWidth(1) / 3), 700);
// Set particular pages
stamp.Pages = new int[] { 1 };
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
// Create stamp text for first item in Table Of Contents
var Document1_Link = new Aspose.Pdf.Facades.Stamp();
Document1_Link.BindLogo(new FormattedText("1 - Link to Document 1", System.Drawing.Color.Black, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 12));
// Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
Document1_Link.SetOrigin(150, 650);
// Set particular pages on which stamp should be displayed
Document1_Link.Pages = new int[] { 1 };
// Add stamp to PDF file
fileStamp.AddStamp(Document1_Link);
// Create stamp text for second item in Table Of Contents
var Document2_Link = new Aspose.Pdf.Facades.Stamp();
Document2_Link.BindLogo(new FormattedText("2 - Link to Document 2", System.Drawing.Color.Black, System.Drawing.Color.Transparent, Aspose.Pdf.Facades.FontStyle.Helvetica, EncodingType.Winansi, true, 12));
// Specify the origin of Stamp. We are getting the page width and specifying the X coordinate for stamp
Document2_Link.SetOrigin(150, 620);
// Set particular pages on which stamp should be displayed
Document2_Link.Pages = new int[] { 1 };
// Add stamp to PDF file
fileStamp.AddStamp(Document2_Link);
// Save updated PDF file
fileStamp.Save(Document_with_TOC_Heading);
fileStamp.Close();
// Now we need to add Heading for Table Of Contents and links for documents
PdfContentEditor contentEditor = new PdfContentEditor();
// Bind the PDF file in which we added the blank page
contentEditor.BindPdf(Document_with_TOC_Heading);
// Create link for first document
contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 650, 100, 20), 2, 1, System.Drawing.Color.Transparent);
// Create link for Second document
// We have used new PdfFileInfo("d:/pdftest/Input1.pdf").NumberOfPages + 2 as PdfFileInfo.NumberOfPages(..) returns the page count for first document
// And 2 is because, second document will start at Input1+1 and 1 for the page containing Table Of Contents.
contentEditor.CreateLocalLink(new System.Drawing.Rectangle(150, 620, 100, 20), new PdfFileInfo(dataDir + "Input1.pdf").NumberOfPages + 2, 1, System.Drawing.Color.Transparent);
// Save updated PDF
contentEditor.Save( dataDir + "Concatenated_Table_Of_Contents.pdf");
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
// Save concatenated output file
pdfEditor.Concatenate(new FileStream(dataDir + "input1.pdf", FileMode.Open), new FileStream(dataDir + "input2.pdf", FileMode.Open), new FileStream(dataDir + "ConcatenatePdfFilesAndCreateTOC_out.pdf", FileMode.Create));
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Insert a blank page at the begining of concatenated file to display Table of Contents
Aspose.Pdf.Document concatenated_pdfDocument = new Aspose.Pdf.Document(new FileStream(dataDir + "Concatenated_Table_Of_Contents.pdf", FileMode.Open));
// Insert a empty page in a PDF
concatenated_pdfDocument.Pages.Insert(1);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Set input and output file paths
string inputFile1 = dataDir + "inFile1.pdf";
string inputFile2 = dataDir + "inFile2.pdf";
string outFile = dataDir + "ConcatenatePDFForms_out.pdf";
// Instantiate PdfFileEditor Object
PdfFileEditor fileEditor = new PdfFileEditor();
// To keep unique field Id for all the fields
fileEditor.KeepFieldsUnique = true;
// Format of the suffix which is added to field name to make it unique when forms are concatenated.
fileEditor.UniqueSuffix = "_%NUM%";
// Concatenate the files into a resultant Pdf file
fileEditor.Concatenate(inputFile1, inputFile2, outFile);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Retrieve names of all the Pdf files in a particular Directory
string[] fileEntries = Directory.GetFiles(dataDir, "*.pdf");
// Get the current System date and set its format
string date = DateTime.Now.ToString("MM-dd-yyyy");
// Get the current System time and set its format
string hoursSeconds = DateTime.Now.ToString("hh-mm");
// Set the value for the final Resultant Pdf document
string masterFileName = date + "_" + hoursSeconds + "_out.pdf";
// Instantiate PdfFileEditor object
Aspose.Pdf.Facades.PdfFileEditor pdfEditor = new PdfFileEditor();
// Call Concatenate method of PdfFileEditor object to concatenate all input files
// Into a single output file
pdfEditor.Concatenate(fileEntries, dataDir + masterFileName);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create a file stream for FDF file - input file
System.IO.FileStream fdfInputStream = new FileStream(dataDir + "inFile.pdf", FileMode.Open);
// Create a file stream for XML file - output file
System.IO.FileStream xmlOutputStream = new FileStream(dataDir + "ConvertPdfToXML_out.xml", FileMode.Create);
// Create a file stream for XML file - output file
FormDataConverter.ConvertFdfToXml(fdfInputStream, xmlOutputStream);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// New a object of Class PdfContentEditor
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(dataDir + "inFile.pdf");
// Creating child items of a chapter, in this example, the first child item also include a child item.
Bookmark bm11 = new Bookmark();
// Set the action type of BookMark
bm11.Action = "GoTo";
// Set the BookMark Destination page
bm11.PageNumber = 3;
// Set the BookMark title.
bm11.Title = "Section - 1.1.1";
Bookmark bm1 = new Bookmark();
bm1.Action = "GoTo";
bm1.PageNumber = 2;
bm1.Title = "Section - 1.1";
Aspose.Pdf.Facades.Bookmarks bms1 = new Aspose.Pdf.Facades.Bookmarks();
bms1.Add(bm11);
bm1.ChildItems = bms1;
// Creating a child item of a chapter.
Bookmark bm2 = new Bookmark();
bm2.Action = "GoTo";
bm2.PageNumber = 4;
bm2.Title = "Section - 1.2";
// Creating a chapter (Parent Level Bookmark)
Bookmark bm = new Bookmark();
bm.Action = "GoTo";
bm.PageNumber = 1;
bm.Title = "Chapter - 1";
Aspose.Pdf.Facades.Bookmarks bms = new Aspose.Pdf.Facades.Bookmarks();
// Add the Section - 1.1, bookmark to bookmarks collection
bms.Add(bm1);
// Add the Section - 1.2, bookmark to bookmarks collection
bms.Add(bm2);
// Add the Bookmarks collection as child_Item of Chapter_Level bookmark
bm.ChildItems = bms;
// Creating a chapter (Parent Level Bookmark)
Bookmark bm_parent2 = new Bookmark();
bm_parent2.Action = "GoTo";
bm_parent2.PageNumber = 5;
bm_parent2.Title = "Chapter - 2";
// Creating a child item of a chapter.
Bookmark bm22 = new Bookmark();
bm22.Action = "GoTo";
bm22.PageNumber = 6;
bm22.Title = "Section - 2.1";
Aspose.Pdf.Facades.Bookmarks bms_parent2 = new Aspose.Pdf.Facades.Bookmarks();
// Add the Section - 2.1, bookmark to bookmarks collection
bms_parent2.Add(bm22);
// Add the Bookmarks collection as child_Item of Chapter2_Level bookmark
bm_parent2.ChildItems = bms_parent2;
// Saves the result PDF to file
editor.Save(dataDir + "Nested_BookMarks_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create instance of PdfFileInfo object
Aspose.Pdf.Facades.PdfFileInfo fInfo = new Aspose.Pdf.Facades.PdfFileInfo(dataDir + "inFile1.pdf");
// Retrieve all existing custom attributes
System.Collections.Hashtable hTable = new Hashtable(fInfo.Header);
IDictionaryEnumerator enumerator = hTable.GetEnumerator();
while (enumerator.MoveNext())
{
string output = enumerator.Key.ToString() + " " + enumerator.Value;
}
// Set new customer attribute as meta info
fInfo.SetMetaInfo("CustomAttribute", "test value");
// Get custom attribute from meta info by specifying attribute/property name
string value = fInfo.GetMetaInfo("CustomAttribute");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// First a input pdf file should be assigned
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(dataDir + "FilledForm.pdf");
// Get all field names
String[] allfields = form.FieldNames;
// Create an array which will hold the location coordinates of Form fields
System.Drawing.Rectangle[] box = new System.Drawing.Rectangle[allfields.Length];
for (int i = 0; i < allfields.Length; i++)
{
// Get the appearance attributes of each field, consequtively
FormFieldFacade facade = form.GetFieldFacade(allfields[i]);
// Box in FormFieldFacade class holds field's location.
box[i] = facade.Box;
}
form.Save(dataDir + "DifferenceBetweenFile_out.pdf");
Document document = new Document(dataDir + "FilledForm - 2.pdf");
// Now we need to add a textfield just upon the original one
FormEditor editor = new FormEditor(document);
for (int i = 0; i < allfields.Length; i++)
{
// Add text field beneath every existing form field
editor.AddField(FieldType.Text, "TextField" + i, allfields[i], 1, box[i].Left, box[i].Top, box[i].Left + 50, box[i].Top + 10);
}
// Close the document
editor.Save(dataDir + "DifferenceBetweenFile_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create a new instance of PdfPageEditor class
Aspose.Pdf.Facades.PdfPageEditor pEditor = new Aspose.Pdf.Facades.PdfPageEditor();
// Bind an existing pdf file
pEditor.BindPdf(dataDir + "FilledForm.pdf");
// Specify an array of pages which need to be manipulated pages can be multiple, here we have specified only one page
pEditor.ProcessPages = new int[] { 1 };
// Alignment related code
// Horizontal alignment
pEditor.HorizontalAlignment = HorizontalAlignment.Right;
// Specify transition type for the pages
pEditor.TransitionType = 2;
// Specify transition duration
pEditor.TransitionDuration = 5;
// Display related code
// Select a page size from the enumeration and assign to property
pEditor.PageSize = PageSize.PageLedger;
// Assign page rotation
pEditor.Rotation = 90;
// Specify zoom factor for the page
pEditor.Zoom = 100;
// Assign display duration for the page
pEditor.DisplayDuration = 5;
// Methods provided by the class page rotation specified already can be fetched using this method
int rotation = pEditor.GetPageRotation(1);
// Already specified page can be fetched with the help of this method
PageSize pagesize = pEditor.GetPageSize(1);
// This method gets the page count
int totalpages = pEditor.GetPages();
// This method changes the origin from (0,0) to specified number
pEditor.MovePosition(100, 100);
// Finally save the output file
pEditor.Save(dataDir + "EditPdfPages_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create an object of PdfXmpMetadata class
Aspose.Pdf.Facades.PdfXmpMetadata xmpMetaData = new Aspose.Pdf.Facades.PdfXmpMetadata();
// Create input and output file streams
FileStream input = new FileStream(dataDir + "FilledForm.pdf", FileMode.Open);
FileStream output = new FileStream(dataDir + "xmp_out.pdf", FileMode.Create);
// Set input file stream
xmpMetaData.BindPdf(input);
// Add base URL property to xmp metadata
xmpMetaData.Add(DefaultMetadataProperties.BaseURL, "xmlns:pdf=http:// Ns.adobe.com/pdf/1.3/");
// Add creation date property to xmp metadata
xmpMetaData.Add(DefaultMetadataProperties.CreateDate, System.DateTime.Now.ToString());
// Add Metadata Date property to xmp metadata
xmpMetaData.Add(DefaultMetadataProperties.MetadataDate, System.DateTime.Now.ToString());
// Add Creator Tool property to xmp metadata
xmpMetaData.Add(DefaultMetadataProperties.CreatorTool, "Creator Tool Name");
// Add Modify Date to xmp metadata
xmpMetaData.Add(DefaultMetadataProperties.ModifyDate, System.DateTime.Now.ToString());
// Add Nick Name to xmp metadata
xmpMetaData.Add(DefaultMetadataProperties.Nickname, "Test");
// Save xmp meta data in the pdf file
xmpMetaData.Save(output);
// Close input and output file streams
input.Close();
output.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
Document doc = new Document(dataDir + "inFile.pdf");
// Create instance of FormEditor
FormEditor editor = new FormEditor(doc);
// Add field in the PDF file
editor.AddField(FieldType.Text, "field1", 1, 300, 500, 350, 525);
// Add List field in PDF file
editor.AddField(FieldType.ListBox, "field2", 1, 300, 200, 350, 225);
// Add list items
editor.AddListItem("field2", "item 1");
editor.AddListItem("field2", "item 2");
// Add submit button
editor.AddSubmitBtn("submitbutton", 1, "Submit Form", "http:// Testwebsite.com/testpage", 200, 200, 250, 225);
// Delete list item
editor.DelListItem("field2", "item 1");
// Move field to new position
editor.MoveField("field1", 10, 10, 50, 50);
// Remove existing field from the PDF
editor.RemoveField("field1");
// Rename an existing field
editor.RenameField("field1", "newfieldname");
// Reset all visual attributes to empty value
editor.ResetFacade();
// Set the alignment style of a text field
editor.SetFieldAlignment("field1", FormFieldFacade.AlignLeft);
// Set appearance of the field
editor.SetFieldAppearance("field1", AnnotationFlags.NoRotate);
// Set field attributes i.e. ReadOnly, Required
editor.SetFieldAttribute("field1", PropertyFlag.ReadOnly);
// Set field limit
editor.SetFieldLimit("field1", 25);
// Save modifications in the output file
editor.Save(dataDir + "FormEditorFeatures2_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// First a input pdf file should be assigned
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(dataDir + "FilledForm.pdf");
// Get all field names
String[] allfields = form.FieldNames;
// Create an array which will hold the location coordinates of Form fields
System.Drawing.Rectangle[] box = new System.Drawing.Rectangle[allfields.Length];
for (int i = 0; i < allfields.Length; i++)
{
// Get the appearance attributes of each field, consequtively
FormFieldFacade facade = form.GetFieldFacade(allfields[i]);
// Box in FormFieldFacade class holds field's location.
box[i] = facade.Box;
}
form.Save(dataDir + "IdentifyFormFields_1_out.pdf");
Document doc = new Document(dataDir + "FilledForm - 2.pdf");
// Now we need to add a textfield just upon the original one
FormEditor editor = new FormEditor(doc);
for (int i = 0; i < allfields.Length; i++)
{
// Add text field beneath every existing form field
editor.AddField(FieldType.Text, "TextField" + i, allfields[i], 1, box[i].Left, box[i].Top, box[i].Left + 50, box[i].Top + 10);
}
// Close the document
editor.Save(dataDir + "IdentifyFormFields_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
using (FileStream source = File.Open(dataDir + "Input1.pdf", FileMode.Open))
{
MemoryStream ms = new MemoryStream();
// Create Form Object
Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form();
// Open Source File
form.BindPdf(source);
// Fill Text Field
form.FillField("Text1", "Thank you for using Aspose");
// Save the document in Memory Stream
form.Save(ms);
ms.Seek(0, SeekOrigin.Begin);
FileStream dest = new FileStream(dataDir + "JustifyText_out.pdf", FileMode.Create);
// Create formEditor Object
FormEditor formEditor = new FormEditor();
// Open PDF from memory stream
formEditor.BindPdf(ms);
// Set Text Alignment as Justified
formEditor.Facade.Alignment = FormFieldFacade.AlignJustified;
// Decorate form field.
formEditor.DecorateField();
// Save te resultant file.
formEditor.Save(dest);
// Close file stream
dest.Close();
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create PdfPageEditor object
PdfPageEditor pEdit = new PdfPageEditor();
// Rotate odd pages at 180 degrees
pEdit.BindPdf(dataDir + "inFile1.pdf");
pEdit.ProcessPages = new int[] { 1 };
pEdit.Rotation = 180;
pEdit.Save(dataDir + "Aspose.Pdf.Facades_rotate_180_out.pdf");
// Rotate even pages at 270 degrees
pEdit.BindPdf(dataDir + "inFile2.pdf");
pEdit.ProcessPages = new int[] { 1 };
pEdit.Rotation = 270;
pEdit.Save(dataDir + "Aspose.Pdf.Facades_rotate_270_out.pdf");
// Find at what degrees a page was rotated
pEdit.BindPdf(dataDir + "inFile.pdf");
int degrees = pEdit.GetPageRotation(1);
pEdit = null;
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create an object of PdfAnnotationEditor class
PdfAnnotationEditor editor = new PdfAnnotationEditor();
// Bind input PDF file
editor.BindPdf(dataDir + "inFile.pdf");
// Create a new object of type Annotation to modify annotation attributes
Aspose.Pdf.Annotations.FreeTextAnnotation annotation = new Aspose.Pdf.Annotations.FreeTextAnnotation(
editor.Document.Pages[1],
new Aspose.Pdf.Rectangle(200, 400, 400, 600),
new Aspose.Pdf.Annotations.DefaultAppearance("TimesNewRoman", 14, System.Drawing.Color.Orange));
// Set new annotation attributees
annotation.Subject = "technical article";
// Modify annotations in the PDF file
editor.ModifyAnnotations(1, 5, annotation);
// Delete all the annotations of type Stamp
editor.DeleteAnnotation("Stamp");
// Extract annotations to an array list
// String[] annType = { "Text" };
Enum[] annotType = { Aspose.Pdf.Annotations.AnnotationType.FreeText, Aspose.Pdf.Annotations.AnnotationType.Line };
ArrayList list = (ArrayList)editor.ExtractAnnotations(1, 5, annotType);
for (int index = 0; index < list.Count; index++)
{
Aspose.Pdf.Annotations.Annotation list_annotation = (Aspose.Pdf.Annotations.Annotation)list[index];
Console.WriteLine(list_annotation.Contents);
}
// Import annotations from another PDF file
string[] importFrom = new string[1];
importFrom[0] = dataDir + "inFile2.pdf";
editor.ImportAnnotations(importFrom);
// Finally save the output PDF file
editor.Save(dataDir + "PdfAnnotationEditorFeatures_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Instantiate a memoryStream object to hold the extracted text from Document
MemoryStream ms = new MemoryStream();
// Instantiate PdfExtractor object
PdfExtractor extractor = new PdfExtractor();
// Bind the input PDF document to extractor
extractor.BindPdf(dataDir + "FilledForm.pdf");
// Extract text from the input PDF document
extractor.ExtractText();
bool containsText = false;
bool containsImage = false;
// Save the extracted text to a text file
extractor.GetText(ms);
// Check if the MemoryStream length is greater than or equal to 1
if (ms.Length >= 1)
containsText = true;
// Extract images from the input PDF document
extractor.ExtractImage();
// Calling HasNextImage method in while loop. When images will finish, loop will exit
if (extractor.HasNextImage())
containsImage = true;
// Now find out whether this PDF is text only or image only
if (containsText == true && containsImage == false)
Console.WriteLine("PDF contains text only");
else if (containsText == false && containsImage == true)
Console.WriteLine("PDF contains image only");
else if (containsText == true && containsImage == true)
Console.WriteLine("PDF contains both text and image");
else if (containsText == false && containsImage == false)
Console.WriteLine("PDF contains neither text or nor image");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create an instance of PdfExtractor class
PdfExtractor extractor = new PdfExtractor();
// Set PDF file password
extractor.Password = "";
// Specify start and end pages of the PDF
extractor.StartPage = 1;
extractor.EndPage = 10;
// Bind PDF file with the extractor object
extractor.BindPdf( dataDir + "inFile.pdf");
// Extract all text from the PDF
extractor.ExtractText();
// Save extracted text in a text file
extractor.GetText(dataDir + "PdfExtractorFeatures_text_out.txt");
// Text of individual pages can also be saved individually in single text files
if (extractor.HasNextPageText())
{
extractor.GetNextPageText(dataDir + DateTime.Now.Ticks.ToString() + "_out.txt");
}
// Extract images from PDF file
extractor.ExtractImage();
// Save each individual image in an image file
if (extractor.HasNextImage())
{
extractor.GetNextImage(dataDir + DateTime.Now.Ticks.ToString() + "_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
// Extract attachments
extractor.ExtractAttachment();
extractor.GetAttachment(dataDir);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create instance of PdfFileEditor class
PdfFileEditor pdfEditor = new PdfFileEditor();
// Append pages from input file to the port file and save in output file
int start = 1;
int end = 3;
pdfEditor.Append(dataDir + "inFile.pdf", dataDir + "portFile.pdf", start, end, dataDir + "outFile.pdf");
// Concatenate two files and save in the third one
pdfEditor.Concatenate(dataDir + "inFile1.pdf", dataDir + "inFile2.pdf", dataDir + "outFile.pdf");
// Delete specified number of pages from the file
int[] pages = new int[] { 1, 2, 4, 10 };
pdfEditor.Delete(dataDir + "inFile.pdf", pages, dataDir + "outFile.pdf");
// Extract any pages from the file
start = 0;
end = 3;
pdfEditor.OwnerPassword = "ownerpass";
pdfEditor.Extract(dataDir + "inFile.pdf", start, end, dataDir + "outFile.pdf");
// Insert pages from another file into the output file at a specified position
start = 2;
end = 5;
pdfEditor.Insert(dataDir + "inFile.pdf", 4, dataDir + "portFile.pdf", start, end, dataDir + "outFile.pdf");
// Make booklet
pdfEditor.MakeBooklet(dataDir + "inFile.Pdf", dataDir + "outFile.Pdf");
// Make N-Ups
pdfEditor.MakeNUp(dataDir + "inFile.pdf", dataDir + "nupOutFile.pdf", 3, 2);
// Split the front part of the file
pdfEditor.SplitFromFirst(dataDir + "inFile.pdf", 3, dataDir + "outFile.pdf");
// Split the rear part of the file
pdfEditor.SplitToEnd(dataDir + "inFile.pdf", 3, dataDir + "outFile.pdf");
// Split to individual pages
int fileNum = 1;
MemoryStream[] outBuffer = pdfEditor.SplitToPages(dataDir + "inFile.pdf");
foreach (MemoryStream aStream in outBuffer)
{
FileStream outStream = new FileStream("oneByone" + fileNum.ToString() + ".pdf",
FileMode.Create);
aStream.WriteTo(outStream);
outStream.Close();
fileNum++;
}
// Split to several multi-page pdf documents
fileNum = 1;
int[][] numberofpage = new int[][] { new int[] { 1, 4 }};
MemoryStream[] outBuffer2 = pdfEditor.SplitToBulks(dataDir + "inFile.pdf", numberofpage);
foreach (MemoryStream aStream in outBuffer2)
{
FileStream outStream = new FileStream("oneByone" + fileNum.ToString() + ".pdf",
FileMode.Create);
aStream.WriteTo(outStream);
outStream.Close();
fileNum++;
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
Document doc = new Document(dataDir + "inFile.pdf");
// Create FormEditor object
FormEditor editor = new FormEditor(doc);
// Add signature fields
editor.AddField(FieldType.Signature, "Signature from Alice", 1, 10, 10, 110, 110);
editor.AddField(FieldType.Signature, "Signature from John", 1, 120, 150, 220, 250);
editor.AddField(FieldType.Signature, "Signature from Smith", 1, 300, 200, 400, 300);
// Save the form
editor.Save(dataDir + "AddSignatureFields_1_out.pdf");
Document doc2 = new Document(dataDir + "inFile2.pdf");
// Add signature to any of the signature fields
PdfFileSignature pdfSign = new PdfFileSignature(doc2);
pdfSign.Sign("Signature from John", "Signature Reason", "John", "Kharkov", new PKCS1("inFile1.pdf", "password"));
// Each time new signature is added you must save the document
pdfSign.Save(dataDir + "AddSignatureFields_2_out.pdf");
Document doc3 = new Document(dataDir + "FilledForm.pdf");
// Add second signature
PdfFileSignature pdfSign2 = new PdfFileSignature(doc3);
pdfSign2.Sign("Signature from Alice", "Signature Reason", "Alice", "Odessa", new PKCS1(dataDir + "FilledForm - 2.pfx", "password"));
// Each time new signature is added you must save the document
pdfSign2.Save(dataDir + "AddSignatureFields_3_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
Document doc = new Document(dataDir + "inFile.pdf");
// Create PdfFileSignature object and bind input and output PDF files
PdfFileSignature pdfSign = new PdfFileSignature(doc);
// Create a rectangle for signature location
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100);
// Set signature appearance
pdfSign.SignatureAppearance = dataDir + "aspose-logo.jpg";
// Create any of the three signature types
PKCS1 signature = new PKCS1(dataDir + "inFile2.pdf", "password");
pdfSign.Sign(1, "Signature Reason", "Alice", "Odessa", true, rect, signature);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create PdfFileSignature object
PdfFileSignature pdfVerify = new PdfFileSignature();
// Bind input PDF file
pdfVerify.BindPdf(dataDir + "inFile.pdf");
// Check if PDF contains signature
bool isSigned = pdfVerify.ContainsSignature();
// All signatures have names Signaure#, this names kit generates automatically
bool isSignatureVerified = pdfVerify.VerifySignature("Signature1");
// However we can set necessary name manualy if we use signature fields (see below)
bool isSignatureVerified2 = pdfVerify.VerifySignature("Signature from Alice");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
public class WinAPIIndexBitmapConverter : IIndexBitmapConverter
{
public Bitmap Get1BppImage(Bitmap src)
{
return CopyToBpp(src, 1);
}
public Bitmap Get4BppImage(Bitmap src)
{
return CopyToBpp(src, 4);
}
public Bitmap Get8BppImage(Bitmap src)
{
return CopyToBpp(src, 8);
}
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleDC(IntPtr hdc);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern int DeleteDC(IntPtr hdc);
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern int BitBlt(IntPtr hdcDst, int xDst, int yDst, int w, int h, IntPtr hdcSrc, int xSrc, int ySrc, int rop);
static int SRCCOPY = 0x00CC0020;
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO bmi, uint Usage, out IntPtr bits, IntPtr hSection, uint dwOffset);
static uint BI_RGB = 0;
static uint DIB_RGB_COLORS = 0;
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct BITMAPINFO
{
public uint biSize;
public int biWidth, biHeight;
public short biPlanes, biBitCount;
public uint biCompression, biSizeImage;
public int biXPelsPerMeter, biYPelsPerMeter;
public uint biClrUsed, biClrImportant;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 256)]
public uint[] cols;
}
static uint MAKERGB(int r, int g, int b)
{
return ((uint)(b & 255)) | ((uint)((r & 255) << 8)) | ((uint)((g & 255) << 16));
}
////////////
/// <summary>
/// Copies a bitmap into a 1bpp/8bpp bitmap of the same dimensions, fast
/// </summary>
/// <param name="b">original bitmap</param>
/// <param name="bpp">1 or 8, target bpp</param>
/// <returns>a 1bpp copy of the bitmap</returns>
private Bitmap CopyToBpp(System.Drawing.Bitmap b, int bpp)
{
if (bpp != 1 && bpp != 8 && bpp != 4) throw new System.ArgumentException("1 or 4 or 8 ", "bpp");
// Plan: built into Windows GDI is the ability to convert
// Bitmaps from one format to another. Most of the time, this
// Job is actually done by the graphics hardware accelerator card
// And so is extremely fast. The rest of the time, the job is done by
// Very fast native code.
// We will call into this GDI functionality from C#. Our plan:
// (1) Convert our Bitmap into a GDI hbitmap (ie. copy unmanaged->managed)
// (2) Create a GDI monochrome hbitmap
// (3) Use GDI "BitBlt" function to copy from hbitmap into monochrome (as above)
// (4) Convert the monochrone hbitmap into a Bitmap (ie. copy unmanaged->managed)
int w = b.Width, h = b.Height;
IntPtr hbm = b.GetHbitmap(); // This is step (1)
//
// Step (2): create the monochrome bitmap.
// "BITMAPINFO" is an interop-struct which we define below.
// In GDI terms, it's a BITMAPHEADERINFO followed by an array of two RGBQUADs
BITMAPINFO bmi = new BITMAPINFO();
bmi.biSize = 40; // The size of the BITMAPHEADERINFO struct
bmi.biWidth = w;
bmi.biHeight = h;
bmi.biPlanes = 1; // "planes" are confusing. We always use just 1. Read MSDN for more info.
bmi.biBitCount = (short)bpp; // Ie. 1bpp or 8bpp
bmi.biCompression = BI_RGB; // Ie. the pixels in our RGBQUAD table are stored as RGBs, not palette indexes
bmi.biSizeImage = (uint)(((w + 7) & 0xFFFFFFF8) * h / 8);
bmi.biXPelsPerMeter = 1000000; // Not really important
bmi.biYPelsPerMeter = 1000000; // Not really important
// Now for the colour table.
uint ncols = (uint)1 << bpp; // 2 colours for 1bpp; 256 colours for 8bpp
bmi.biClrUsed = ncols;
bmi.biClrImportant = ncols;
bmi.cols = new uint[256]; // The structure always has fixed size 256, even if we end up using fewer colours
if (bpp == 1)
{
bmi.cols[0] = MAKERGB(0, 0, 0); bmi.cols[1] = MAKERGB(255, 255, 255);
}
else if (bpp == 4)
{
// For 8bpp we've created an palette with just greyscale colours.
// You can set up any palette you want here. Here are some possibilities:
// Rainbow:
bmi.biClrUsed = 16;
bmi.biClrImportant = 16;
int[] colv = new int[16] { 8, 24, 38, 56, 72, 88, 104, 120, 136, 152, 168, 184, 210, 216, 232, 248 };
//
for (int i = 0; i < 16; i++) bmi.cols[i] = MAKERGB(colv[i], colv[i], colv[i]);
}
else if (bpp == 8)
{
// For 8bpp we've created an palette with just greyscale colours.
// You can set up any palette you want here. Here are some possibilities:
// Rainbow:
bmi.biClrUsed = 216; bmi.biClrImportant = 216; int[] colv = new int[6] { 0, 51, 102, 153, 204, 255 };
for (int i = 0; i < 216; i++) bmi.cols[i] = MAKERGB(colv[i / 36], colv[(i / 6) % 6], colv[i % 6]);
// Optimal: a difficult topic: http:// En.wikipedia.org/wiki/Color_quantization
}
//
// Now create the indexed bitmap "hbm0"
IntPtr bits0; // Not used for our purposes. It returns a pointer to the raw bits that make up the bitmap.
IntPtr hbm0 = CreateDIBSection(IntPtr.Zero, ref bmi, DIB_RGB_COLORS, out bits0, IntPtr.Zero, 0);
//
// Step (3): use GDI's BitBlt function to copy from original hbitmap into monocrhome bitmap
// GDI programming is kind of confusing... nb. The GDI equivalent of "Graphics" is called a "DC".
IntPtr sdc = GetDC(IntPtr.Zero); // First we obtain the DC for the screen
// Next, create a DC for the original hbitmap
IntPtr hdc = CreateCompatibleDC(sdc); SelectObject(hdc, hbm);
// And create a DC for the monochrome hbitmap
IntPtr hdc0 = CreateCompatibleDC(sdc); SelectObject(hdc0, hbm0);
// Now we can do the BitBlt:
BitBlt(hdc0, 0, 0, w, h, hdc, 0, 0, SRCCOPY);
// Step (4): convert this monochrome hbitmap back into a Bitmap:
Bitmap b0 = System.Drawing.Image.FromHbitmap(hbm0);
//
// Finally some cleanup.
DeleteDC(hdc);
DeleteDC(hdc0);
ReleaseDC(IntPtr.Zero, sdc);
DeleteObject(hbm);
DeleteObject(hbm0);
//
return b0;
}
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create PdfConverter object and bind input PDF file
PdfConverter pdfConverter = new PdfConverter();
pdfConverter.BindPdf(dataDir + "inFile.pdf");
pdfConverter.DoConvert();
// Create TiffSettings object and set CompressionType
TiffSettings tiffSettings = new TiffSettings();
// Convert to TIFF image
pdfConverter.SaveAsTIFF(dataDir + "PDFToTIFFConversion_out.tif", 300, 300, tiffSettings, new WinAPIIndexBitmapConverter());
pdfConverter.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Create PdfConverter object and bind input PDF file
PdfConverter pdfConverter = new PdfConverter();
pdfConverter.Resolution = new Aspose.Pdf.Devices.Resolution(300);
pdfConverter.BindPdf(dataDir + "inFile.pdf");
pdfConverter.DoConvert();
// Create TiffSettings object and set ColorDepth
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.Depth = ColorDepth.Format1bpp;
// Convert to TIFF image
pdfConverter.SaveAsTIFF(dataDir + "PDFToTIFFConversion_out.tif", 300, 300, tiffSettings);
pdfConverter.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Set path of the image to be set as watermark
string imageFile = dataDir + "aspose-logo.jpg";
// Set input file path
string inFile = dataDir + "inFile.pdf";
// Set output file path
string outFile = dataDir + "RotatingStamp_out.pdf";
// Create PdfFileInfo object to get height and width of the pages
PdfFileInfo fileInfo = new PdfFileInfo(inFile);
// Create Stamp object
Aspose.Pdf.Facades.Stamp aStamp = new Aspose.Pdf.Facades.Stamp();
// Bind image file with the Stamp object
aStamp.BindImage(imageFile);
// Specify whether the stamp will be added as a background or not
aStamp.IsBackground = false;
// Specifies at which pages to add the watermark
aStamp.Pages = new int[] { 1 };
// Specifies the watermark rotation - rotate at 90 degrees the stamp is rotated about the center point of the stamp object
aStamp.Rotation = 90;
// Specifies the position of stamp - lower left corner of the stamp
aStamp.SetOrigin(fileInfo.GetPageWidth(1) / 2, fileInfo.GetPageHeight(1) / 2);
// Set the size of the watermark
aStamp.SetImageSize(100, 100);
Document doc = new Document(inFile);
// Create PdfFileStamp class to bind input and output files
PdfFileStamp stamper = new PdfFileStamp(doc);
// Add the stamp in the PDF file
stamper.AddStamp(aStamp);
// Close the PdfFileStamp object
stamper.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
Stream src = new FileStream(dataDir + "log.xml", FileMode.Open, FileAccess.Read);
Stream dest = new FileStream(dataDir + "XMLToPdf_out.pdf", FileMode.Create, FileAccess.ReadWrite);
FormDataConverter.ConvertXmlToFdf(src, dest);
dest.Close();
src.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
// Open document
PdfFileMend mender = new PdfFileMend();
// Create PdfFileMend object to add text
mender.BindPdf(dataDir + "AddText.pdf");
// Create formatted text
FormattedText text = new FormattedText("Aspose - Your File Format Experts!", System.Drawing.Color.AliceBlue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, true, 14);
// Set whether to use Word Wrap or not and using which mode
mender.IsWordWrap = true;
mender.WrapMode = WordWrapMode.Default;
// Add text in the PDF file
mender.AddText(text, 1, 100, 200, 200, 400);
// Save changes
mender.Save(dataDir + "AddText_out.pdf");
// Close PdfFileMend object
mender.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
// Open input PDF
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(dataDir+ "ExtractText.pdf");
// Use parameterless ExtractText method
pdfExtractor.ExtractText();
MemoryStream tempMemoryStream = new MemoryStream();
pdfExtractor.GetText(tempMemoryStream);
string text = "";
// Specify Unicode encoding type in StreamReader constructor
using (StreamReader streamReader = new StreamReader(tempMemoryStream, Encoding.Unicode))
{
streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
text = streamReader.ReadToEnd();
}
File.WriteAllText(dataDir+ "output_out.txt", text);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
// Open input PDF
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(dataDir+ "ExtractText-Page.pdf");
// Use parameterless ExtractText method
pdfExtractor.ExtractText();
int pageNumber = 1;
while (pdfExtractor.HasNextPageText())
{
MemoryStream tempMemoryStream = new MemoryStream();
pdfExtractor.GetNextPageText(tempMemoryStream);
string text = "";
// Specify Unicode encoding type in StreamReader constructor
using (StreamReader streamReader = new
StreamReader(tempMemoryStream, Encoding.Unicode))
{
streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
text = streamReader.ReadToEnd();
}
File.WriteAllText(dataDir+ "output" + pageNumber + "_out.txt", text);
pageNumber++;
}
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
// Open input PDF
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(dataDir+ "ExtractText-PageRange.pdf");
// Specify start and end pages
pdfExtractor.StartPage = 1;
pdfExtractor.EndPage = 1;
// Use parameterless ExtractText method
pdfExtractor.ExtractText();
MemoryStream tempMemoryStream = new MemoryStream();
pdfExtractor.GetText(tempMemoryStream);
string text = "";
// Specify Unicode encoding type in StreamReader constructor
using (StreamReader sr = new StreamReader(tempMemoryStream,Encoding.Unicode))
{
sr.BaseStream.Seek(0, SeekOrigin.Begin);
text = sr.ReadToEnd();
}
File.WriteAllText(dataDir+ "output_out.txt", text);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
// Open input PDF
PdfContentEditor pdfContentEditor = new PdfContentEditor();
pdfContentEditor.BindPdf(dataDir + "ReplaceText.pdf");
// Replace text on all pages
pdfContentEditor.ReplaceText("Hello", "World");
// Save output PDF
pdfContentEditor.Save(dataDir + "ReplaceText_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Text();
// Open input PDF
PdfContentEditor pdfContentEditor = new PdfContentEditor();
pdfContentEditor.BindPdf(dataDir+ "ReplaceText-Page.pdf");
// Replace text on all pages
pdfContentEditor.ReplaceText("Hello", 1, "World");
// Save output PDF
pdfContentEditor.Save(dataDir + "ReplaceTextPage_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
// Open document
PdfFileInfo fileInfo = new PdfFileInfo(dataDir+ "GetFileInfo.pdf");
// Get PDF information
Console.WriteLine("Subject: {0}", fileInfo.Subject);
Console.WriteLine("Title: {0}", fileInfo.Title);
Console.WriteLine("Keywords: {0}", fileInfo.Keywords);
Console.WriteLine("Creator: {0}", fileInfo.Creator);
Console.WriteLine("Creation Date: {0}", fileInfo.CreationDate);
Console.WriteLine("Modification Date: {0}", fileInfo.ModDate);
// Find whether is it valid PDF and it is encrypted as well
Console.WriteLine("Is Valid PDF: {0}", fileInfo.IsPdfFile);
Console.WriteLine("Is Encrypted: {0}", fileInfo.IsEncrypted);
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
// Create PdfXmpMetadata object
PdfXmpMetadata xmpMetaData = new PdfXmpMetadata();
// Bind pdf file to the object
xmpMetaData.BindPdf( dataDir + "input.pdf");
// Get XMP Meta Data properties
Console.WriteLine(": {0}", xmpMetaData[DefaultMetadataProperties.CreateDate].ToString());
Console.WriteLine(": {0}", xmpMetaData[DefaultMetadataProperties.MetadataDate].ToString());
Console.WriteLine(": {0}", xmpMetaData[DefaultMetadataProperties.CreatorTool].ToString());
Console.WriteLine(": {0}", xmpMetaData["customNamespace:UserPropertyName"].ToString());
Console.ReadLine();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
// Instantiate Document instance
Document doc = new Document(dataDir + "input.pdf");
// Instantiate blank Document instance
Document dest = new Document();
// Create PdfFileEditor object
PdfFileEditor fileEditor = new PdfFileEditor();
fileEditor.AddPageBreak(doc, dest, new PdfFileEditor.PageBreak[]
{
new PdfFileEditor.PageBreak(1, 450)
});
// Save resultant file
dest.Save(dataDir + "PageBreak_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
// Create PdfFileEditor object
PdfFileEditor fileEditor = new PdfFileEditor();
fileEditor.AddPageBreak(dataDir + "input.pdf", dataDir + "PageBreakWithDestPath_out.pdf", new PdfFileEditor.PageBreak[]
{
new PdfFileEditor.PageBreak(1, 450)
});
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
Stream src = new FileStream( dataDir + "input.pdf", FileMode.Open, FileAccess.Read);
Stream dest = new FileStream(dataDir + "PageBreakWithStream_out.pdf", FileMode.Create, FileAccess.ReadWrite);
PdfFileEditor fileEditor = new PdfFileEditor();
fileEditor.AddPageBreak(src, dest, new PdfFileEditor.PageBreak[]
{
new PdfFileEditor.PageBreak(1, 450)
});
dest.Close();
src.Close();
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
// Open document
PdfFileInfo fileInfo = new PdfFileInfo(dataDir+ "SetFileInfo.pdf");
// Set PDF information
fileInfo.Author = "Aspose";
fileInfo.Title = "Hello World!";
fileInfo.Keywords = "Peace and Development";
fileInfo.Creator = "Aspose";
// Save updated file
fileInfo.SaveNewInfo(dataDir+ "SetFileInfo_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
// Open document
PdfContentEditor contentEditor = new PdfContentEditor();
contentEditor.BindPdf(dataDir + "SetViewerPreference.pdf");
// Change Viewer Preferences
contentEditor.ChangeViewerPreference(ViewerPreference.CenterWindow);
contentEditor.ChangeViewerPreference(ViewerPreference.HideMenubar);
contentEditor.ChangeViewerPreference(ViewerPreference.PageModeUseNone);
// Save output PDF file
contentEditor.Save(dataDir+ "SetViewerPreference_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_WorkingDocuments();
// Create PdfXmpMetadata object
PdfXmpMetadata xmpMetaData = new PdfXmpMetadata();
// Bind pdf file to the object
xmpMetaData.BindPdf(dataDir+ "SetXMPMetadata.pdf");
// Add create date
xmpMetaData.Add(DefaultMetadataProperties.CreateDate, System.DateTime.Now.ToString());
// Change meta data date
xmpMetaData[DefaultMetadataProperties.MetadataDate] = System.DateTime.Now.ToString();
// Add creator tool
xmpMetaData.Add(DefaultMetadataProperties.CreatorTool, "Creator tool name");
// Remove modify date
xmpMetaData.Remove(DefaultMetadataProperties.ModifyDate);
// Add user defined property
// Step #1: register namespace prefix and URI
xmpMetaData.RegisterNamespaceURI("customNamespace", "http:// Www.customNameSpaces.com/ns/");
// Step #2: add user property with the prefix
xmpMetaData.Add("customNamespace:UserPropertyName", "UserPropertyValue");
// Change user defined property
xmpMetaData["customNamespace:UserPropertyName"] = "UserPropertyValue2";
// Save xmp meta data in the pdf file
xmpMetaData.Save(dataDir+ "SetXMPMetadata_out.pdf");
// Close the object
xmpMetaData.Close();
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Annotations()
' Open document
Dim contentEditor As New PdfContentEditor()
contentEditor.BindPdf(dataDir & Convert.ToString("AddFreeTextAnnotation.pdf"))
' Create rectangle
Dim rect As New System.Drawing.Rectangle(50, 50, 100, 100)
' Create annotation
contentEditor.CreateFreeText(rect, "Sample content", 1)
' Save updated PDF file
contentEditor.Save(dataDir & Convert.ToString("AddFreeTextAnnotation_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Annotations()
' Instantiate PdfContentEditor object
Dim editor As New PdfContentEditor()
' Bind input PDF file
editor.BindPdf(dataDir & Convert.ToString("CreateFileAnnotation.pdf"))
' The last argumnet is for transparency of icon
editor.CreateFileAttachment(New System.Drawing.Rectangle(50, 50, 10, 10), "here", dataDir & Convert.ToString("AddFreeTextAnnotation.pdf"), 1, "Paperclip", 0.005)
' Save the updated PDF file
editor.Save(dataDir & Convert.ToString("PdfWith_Transparent_Annotation_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Annotations()
' Open document
Dim annotationEditor As New PdfAnnotationEditor()
annotationEditor.BindPdf(dataDir & Convert.ToString("DeleteAllAnnotations.pdf"))
' Delete all annoations
annotationEditor.DeleteAnnotations()
' Save updated PDF
annotationEditor.Save(dataDir & Convert.ToString("DeleteAllAnnotations_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Annotations()
' Open document
Dim annotationEditor As New PdfAnnotationEditor()
annotationEditor.BindPdf(dataDir & Convert.ToString("DeleteAllAnnotations.pdf"))
' Delete specific annoations
annotationEditor.DeleteAnnotations("Text")
' Save updated PDF
annotationEditor.Save(dataDir & Convert.ToString("DeleteSpecificAnnotations_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Annotations()
' Create PdfAnnotationEditor object
Dim AnnotationEditor As New PdfAnnotationEditor()
' Open PDF document
AnnotationEditor.BindPdf(dataDir & Convert.ToString("ExportAnnotations.pdf"))
' Export annotations
Dim fileStream As FileStream = New System.IO.FileStream(dataDir & Convert.ToString("exportannotationsvb.xfdf"), System.IO.FileMode.Create)
Dim annotType As [Enum]() = {AnnotationType.FreeText, AnnotationType.Line}
AnnotationEditor.ExportAnnotationsXfdf(fileStream, 1, 5, annotType)
' Save output PDF
AnnotationEditor.Save(dataDir & Convert.ToString("ExportAnnotations_out_.pdf"))
fileStream.Flush()
fileStream.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Annotations()
' Create PdfAnnotationEditor
Dim annotationEditor As New PdfAnnotationEditor()
' Open PDF document
annotationEditor.BindPdf(dataDir & Convert.ToString("ExtractAnnotations.pdf"))
' Extract annotations
Dim annotType As [Enum]() = {AnnotationType.FreeText, AnnotationType.Line}
Dim annotList As ArrayList = DirectCast(annotationEditor.ExtractAnnotations(1, 2, annotType), ArrayList)
For index As Integer = 0 To annotList.Count - 1
Dim annotation As Annotation = DirectCast(annotList(index), Annotation)
Console.WriteLine(annotation.Contents)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Annotations()
' Create PdfAnnotationEditor object
Dim AnnotationEditor As New PdfAnnotationEditor()
' Open PDF document
AnnotationEditor.BindPdf(dataDir & Convert.ToString("ImportAnnotations.pdf"))
' Import annotations
Dim fileStream As FileStream = New System.IO.FileStream(dataDir & Convert.ToString("annotations.xfdf"), System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim annotType As [Enum]() = {AnnotationType.FreeText, AnnotationType.Line}
AnnotationEditor.ImportAnnotationFromXfdf(fileStream, annotType)
' Save output PDF
AnnotationEditor.Save(dataDir & Convert.ToString("ImportAnnotations_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Annotations()
' Open document
Dim annotationEditor As New Aspose.Pdf.Facades.PdfAnnotationEditor()
annotationEditor.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Create annotation
Dim annotation As New FreeTextAnnotation(annotationEditor.Document.Pages(1), New Aspose.Pdf.Rectangle(200, 400, 400, 600), New DefaultAppearance("TimesNewRoman", 14, System.Drawing.Color.Orange))
annotation.Modified = DateTime.Now
annotation.Contents = "Contents..."
annotation.Subject = "Subject"
annotation.Color = Color.Green
' Modify annotation
annotationEditor.ModifyAnnotations(1, 1, annotation)
' Save updated PDF file
annotationEditor.Save("output_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Attachments()
' Open document
Dim contentEditor As New PdfContentEditor()
contentEditor.BindPdf(dataDir & "AddAttachment.pdf")
' Add attachment
contentEditor.AddDocumentAttachment(dataDir & "test.txt", "Attachment Description")
' Save updated PDF
contentEditor.Save(dataDir & "AddAttachment_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Attachments()
' Open document
Dim contentEditor As New PdfContentEditor()
contentEditor.BindPdf(dataDir & "AddAttachment-Stream.pdf")
' Read file into stream (FileStream or MemoryStream)
Dim fileStream As New FileStream(dataDir & "test.txt", FileMode.Open)
' Add attachment
contentEditor.AddDocumentAttachment(fileStream, "Attachment Name", "Attachment Description")
' Save updated PDF
contentEditor.Save(dataDir & "AddAttachment-Stream_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Attachments()
' Open document
Dim contentEditor As New PdfContentEditor()
contentEditor.BindPdf(dataDir & "DeleteAllAttachments.pdf")
' Delete attachments
contentEditor.DeleteAttachments()
' Save updated PDF
contentEditor.Save(dataDir & "DeleteAllAttachments_out.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Attachments()
' Open document
Dim pdfExtractor As New PdfExtractor()
pdfExtractor.BindPdf(dataDir & "ExtractAllAttachments.pdf")
' Extract attachments
pdfExtractor.ExtractAttachment()
' Get extracted attachments
pdfExtractor.GetAttachment(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Attachments()
' Open document
Dim pdfExtractor As New PdfExtractor()
pdfExtractor.BindPdf(dataDir & "GetAttachmentNames.pdf")
' Extract attachments
pdfExtractor.ExtractAttachment()
' Get attachment names
Dim attachmentNames As System.Collections.IList = CType(pdfExtractor.GetAttachNames(), System.Collections.IList)
For Each attachmentName As String In attachmentNames
Console.WriteLine("Name : {0}", attachmentName)
Next attachmentName
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Create bookmark
Dim boomark As New Bookmark()
boomark.PageNumber = 1
boomark.Title = "New Bookmark"
' Create PdfBookmarkEditor class
Dim bookmarkEditor As New PdfBookmarkEditor()
' Bind PDF document
bookmarkEditor.BindPdf(dataDir & "AddBookmark.pdf")
' Create bookmarks
bookmarkEditor.CreateBookmarks(boomark)
' Save updated document
bookmarkEditor.Save(dataDir & "AddBookmark_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Create bookmarks
Dim bookmarks As New Aspose.Pdf.Facades.Bookmarks()
Dim childBookmark1 As New Bookmark()
childBookmark1.PageNumber = 1
childBookmark1.Title = "First Child"
Dim childBookmark2 As New Bookmark()
childBookmark2.PageNumber = 2
childBookmark2.Title = "Second Child"
bookmarks.Add(childBookmark1)
bookmarks.Add(childBookmark2)
Dim bookmark As New Bookmark()
bookmark.Action = "GoTo"
bookmark.PageNumber = 1
bookmark.Title = "Parent"
bookmark.ChildItems = bookmarks
' Create PdfBookmarkEditor class
Dim bookmarkEditor As New PdfBookmarkEditor()
' Bind PDF document
bookmarkEditor.BindPdf(dataDir & Convert.ToString("AddChildBookmark.pdf"))
' Create bookmarks
bookmarkEditor.CreateBookmarks(bookmark)
' Save updated document
bookmarkEditor.Save(dataDir & Convert.ToString("AddChildBookmark_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Open document
Dim bookmarkEditor As New PdfBookmarkEditor()
bookmarkEditor.BindPdf(dataDir & Convert.ToString("CreateBookmark-Page.pdf"))
' Create bookmark of a particular page
bookmarkEditor.CreateBookmarkOfPage("Bookmark Name", 2)
' Save updated PDF file
bookmarkEditor.Save(dataDir & Convert.ToString("CreateBookmark-Page_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Open document
Dim bookmarkEditor As New PdfBookmarkEditor()
bookmarkEditor.BindPdf(dataDir & Convert.ToString("CreateBookmark-Page.pdf"))
' Bookmark name list
Dim bookmarkList As String() = {"First"}
' Page list
Dim pageList As Integer() = {1}
' Create bookmark of a range of pages
bookmarkEditor.CreateBookmarkOfPage(bookmarkList, pageList)
' Save updated PDF file
bookmarkEditor.Save(dataDir & "CreateBookmarkPageRange_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Open document
Dim bookmarkEditor As New PdfBookmarkEditor()
bookmarkEditor.BindPdf(dataDir & Convert.ToString("CreateBookmarksAll.pdf"))
' Create bookmark of all pages
bookmarkEditor.CreateBookmarks()
' Save updated PDF file
bookmarkEditor.Save(dataDir & Convert.ToString("Output_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Open document
Dim bookmarkEditor As New PdfBookmarkEditor()
bookmarkEditor.BindPdf(dataDir & Convert.ToString("CreateBookmarks-PagesProperties.pdf"))
' Create bookmark of all pages
bookmarkEditor.CreateBookmarks(System.Drawing.Color.Green, True, True)
' Save updated PDF file
bookmarkEditor.Save(dataDir & Convert.ToString("CreateBookmarks-PagesProperties_out.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Open document
Dim bookmarkEditor As New PdfBookmarkEditor()
bookmarkEditor.BindPdf(dataDir & Convert.ToString("DeleteABookmark.pdf"))
' Delete bookmark
bookmarkEditor.DeleteBookmarks("Page2")
' Save updated PDF file
bookmarkEditor.Save(dataDir & Convert.ToString("DeleteABookmark_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Open document
Dim bookmarkEditor As New PdfBookmarkEditor()
bookmarkEditor.BindPdf(dataDir & Convert.ToString("DeleteAllBookmarks.pdf"))
' Delete bookmark
bookmarkEditor.DeleteBookmarks()
' Save updated PDF file
bookmarkEditor.Save(dataDir & Convert.ToString("DeleteAllBookmarks_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Create PdfBookmarkEditor object
Dim bookmarkEditor As New PdfBookmarkEditor()
' Open PDF file
bookmarkEditor.BindPdf(dataDir & Convert.ToString("ExportToXML.pdf"))
' Export bookmarks
bookmarkEditor.ExportBookmarksToXML(dataDir & Convert.ToString("bookmarks.xml"))
' Save updated PDF
bookmarkEditor.Save(dataDir & Convert.ToString("ExportToXML_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Create PdfBookmarkEditor
Dim bookmarkEditor As New PdfBookmarkEditor()
' Open PDF file
bookmarkEditor.BindPdf(dataDir & Convert.ToString("ExtractBookmarks.pdf"))
' Extract bookmarks
Dim bookmarks As Aspose.Pdf.Facades.Bookmarks = bookmarkEditor.ExtractBookmarks()
For Each bookmark As Bookmark In bookmarks
Console.WriteLine("Title: {0}", bookmark.Title)
Console.WriteLine("Page Number: {0}", bookmark.PageNumber)
Next
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Create PdfBookmarkEditor
Dim bookmarkEditor As New PdfBookmarkEditor()
' Open PDF file
bookmarkEditor.BindPdf(dataDir & Convert.ToString("GetFromPDF.PDF"))
' Extract bookmarks
Dim bookmarks As Aspose.Pdf.Facades.Bookmarks = bookmarkEditor.ExtractBookmarks()
For Each bookmark As Aspose.Pdf.Facades.Bookmark In bookmarks
' Get the title information of bookmark item
Console.WriteLine("Title: {0}", bookmark.Title)
' Get the destination page for bookmark
Console.WriteLine("Page Number: {0}", bookmark.PageNumber)
' Get the information related to associated action with bookmark
Console.WriteLine("Bookmark Action: " + bookmark.Action)
Next
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Create PdfBookmarkEditor class
Dim bookmarkEditor As New PdfBookmarkEditor()
' Open PDF file
bookmarkEditor.BindPdf(dataDir & Convert.ToString("ImportFromXML.pdf"))
' Import bookmarks
bookmarkEditor.ImportBookmarksWithXML(dataDir & Convert.ToString("bookmarks.xml"))
' Save updated PDF file
bookmarkEditor.Save(dataDir & Convert.ToString("ImportFromXML_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Bookmarks()
' Open document
Dim bookmarkEditor As New PdfBookmarkEditor()
bookmarkEditor.BindPdf(dataDir & Convert.ToString("UpdateBookmark.pdf"))
' Update bookmark
bookmarkEditor.ModifyBookmarks("New Bookmark", "New Title")
' Save updated PDF file
bookmarkEditor.Save(dataDir & Convert.ToString("UpdateBookmark_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim formEditor As New FormEditor()
' Open Document
formEditor.BindPdf(dataDir & "AddFormField.pdf")
' Add field
formEditor.AddField(FieldType.Text, "textfield", 1, 100, 100, 200, _
150)
formEditor.AddField(FieldType.CheckBox, "checkboxfield", 1, 100, 200, 200, _
250)
formEditor.AddField(FieldType.ComboBox, "comboboxfield", 1, 100, 300, 200, _
350)
formEditor.AddField(FieldType.ListBox, "listboxfield", 1, 100, 400, 200, _
450)
formEditor.AddField(FieldType.MultiLineText, "multilinetextfield", 1, 100, 500, 200, _
550)
' Save updated file
formEditor.Save(dataDir & "AddFormField_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim form As New FormEditor()
' Open the document and create a FormEditor object
form.BindPdf(dataDir & "AddListItem.pdf")
' Add list field in PDF file
form.AddField(FieldType.ListBox, "listbox", 1, 300, 200, 350, _
225)
' Add list items
form.AddListItem("listbox", "Item 1")
form.AddListItem("listbox", "Item 2")
' Add multiple list items once
Dim listItems As String() = {"Item 3", "Item 4", "Item 5"}
form.AddListItem("listbox", listItems)
' Save updated file
form.Save(dataDir & "AddListItem_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
' Create FormEditor object
Dim formEditor As New FormEditor()
' Open Document
formEditor.BindPdf(dataDir & "CopyInnerField.pdf")
' Copy a field to another page
formEditor.CopyInnerField("textfield", "newfieldname", 1)
' Close and save the output document
formEditor.Save(dataDir & "CopyInnerField_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
' Open document
Dim formEditor As New FormEditor()
' Open the document and create a FormEditor object
formEditor.BindPdf(dataDir & "CopyOuterField.pdf")
' Copy a text field from one document to another one
formEditor.CopyOuterField(dataDir & Convert.ToString("input.pdf"), "textfield", 1)
' Close and save the output document
formEditor.Save(dataDir & Convert.ToString("CopyOuterField_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
' Open document
Dim form As New FormEditor()
' Open the document and create a FormEditor object
form.BindPdf(dataDir & Convert.ToString("DecorateFields.pdf"))
' Create a new facade object
Dim facade As New FormFieldFacade()
' Assign the facade to form editor
form.Facade = facade
' Set the backgroud color as red
facade.BackgroundColor = System.Drawing.Color.Red
' Set the alignment as center
facade.Alignment = FormFieldFacade.AlignCenter
' All text fields will be modified:
form.DecorateField(FieldType.Text)
' Close and validate the modification like this:
form.Save(dataDir & Convert.ToString("DecorateFields_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim form As New FormEditor()
' Open the document and create a FormEditor object
form.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Set field facade
Dim fieldFacade As New FormFieldFacade()
form.Facade = fieldFacade
fieldFacade.BackgroundColor = System.Drawing.Color.Red
fieldFacade.FontSize = 14
' Specify the form field which needs to be decorated
form.DecorateField("textfield")
' Save updated PDF form
form.Save(dataDir & Convert.ToString("DecorateParticularField_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim form As New FormEditor()
' Open the document and create a FormEditor object
form.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Set field facade
Dim fieldFacade As New FormFieldFacade()
form.Facade = fieldFacade
fieldFacade.BackgroundColor = System.Drawing.Color.Red
fieldFacade.FontSize = 14
' Set font for form field
fieldFacade.CustomFont = "CourierNew"
' Specify the form field which needs to be decorated
form.DecorateField("textfield")
' Save updated PDF form
form.Save("SetFont_out_.pdf")
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim formEditor As New FormEditor()
' Open Document
formEditor.BindPdf(dataDir & Convert.ToString("DeleteFormField.pdf"))
' Delete field
formEditor.RemoveField("textfield")
' Save updated file
formEditor.Save(dataDir & Convert.ToString("DeleteFormField_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim form As New FormEditor()
' Open the document and create a FormEditor object
form.BindPdf(dataDir & Convert.ToString("AddListItem.pdf"))
' Delete list item
form.DelListItem("listbox", "Item 2")
' Save updated file
form.Save(dataDir & Convert.ToString("DeleteListItem_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim form As New Aspose.Pdf.Facades.Form()
' Open Document
form.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Create fdf file.
Dim fdfOutputStream As System.IO.FileStream = New FileStream(dataDir & Convert.ToString("student.fdf"), FileMode.Create)
' Export data
form.ExportFdf(fdfOutputStream)
' Close file stream
fdfOutputStream.Close()
' Save updated document
form.Save(dataDir & Convert.ToString("ExportDataToPdf_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim form As New Aspose.Pdf.Facades.Form()
' Open Document
form.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Create xfdf file.
Dim xfdfOutputStream As System.IO.FileStream = New FileStream("student1.xfdf", FileMode.Create)
' Export data
form.ExportXfdf(xfdfOutputStream)
' Close file stream
xfdfOutputStream.Close()
' Save updated document
form.Save(dataDir & Convert.ToString("ExportDataToXFDF_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
' Open document
Dim form As New Aspose.Pdf.Facades.Form()
form.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Create xml file.
Dim xmlOutputStream As System.IO.FileStream = New FileStream(dataDir & Convert.ToString("input.xml"), FileMode.Create)
' Export data
form.ExportXml(xmlOutputStream)
' Close file stream
xmlOutputStream.Close()
' Close the document
form.Dispose()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdf_Forms()
' Open document
Dim pdfDocument As New Document(dataDir & Convert.ToString("FillFormField.pdf"))
' Get a field
Dim textBoxField As TextBoxField = TryCast(pdfDocument.Form("textbox1"), TextBoxField)
' Modify field value
textBoxField.Value = "Value to be filled in the field"
dataDir = dataDir & Convert.ToString("FillFormField_out_.pdf")
' Save updated document
pdfDocument.Save(dataDir)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
' Create Form Object
Dim pdfForm As New Aspose.Pdf.Facades.Form()
' Open Document
pdfForm.BindPdf(dataDir & Convert.ToString("FormField.pdf"))
' Fill the field "textfield" with "Mike".
pdfForm.FillField("textfield", "Mike")
' Save updated file
pdfForm.Save(dataDir & Convert.ToString("FillFormFieldF_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim pdfForm As New Aspose.Pdf.Facades.Form()
' Open Document
pdfForm.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Flatten fields
pdfForm.FlattenAllFields()
' Save output
pdfForm.Save(dataDir & Convert.ToString("FlattenAllFields_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
' Create Form Object
Dim pdfForm As New Aspose.Pdf.Facades.Form()
' Open Document
pdfForm.BindPdf(dataDir & Convert.ToString("FormField.pdf"))
' Get button option values
Dim optionValues = pdfForm.GetButtonOptionValues("Gender")
Dim optionValueEnumerator As IDictionaryEnumerator = optionValues.GetEnumerator()
While optionValueEnumerator.MoveNext()
Console.WriteLine("Key : {0} , Value : {1} ", optionValueEnumerator.Key, optionValueEnumerator.Value)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
' Create Form Object
Dim pdfForm As New Aspose.Pdf.Facades.Form()
' Open Document
pdfForm.BindPdf(dataDir & Convert.ToString("FormField.pdf"))
' Get button option values
Dim optionValue As String = pdfForm.GetButtonOptionCurrentValue("Gender")
Console.WriteLine("Current Value : {0} ", optionValue)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim pdfForm As New Aspose.Pdf.Facades.Form()
' Open Document
pdfForm.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Get field value
Console.WriteLine("Field Value : {0} ", pdfForm.GetField("textfield"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
' Create Form Object
Dim pdfForm As New Aspose.Pdf.Facades.Form()
' Open Document
pdfForm.BindPdf(dataDir & Convert.ToString("FormField.pdf"))
' Get form field facade
Dim fieldFacade As FormFieldFacade = pdfForm.GetFieldFacade("textfield")
' Get facade values
Console.WriteLine("Alignment : {0} ", fieldFacade.Alignment)
Console.WriteLine("Background Color : {0} ", fieldFacade.BackgroundColor)
Console.WriteLine("Border Color : {0} ", fieldFacade.BorderColor)
Console.WriteLine("Border Style : {0} ", fieldFacade.BorderStyle)
Console.WriteLine("Border Width : {0} ", fieldFacade.BorderWidth)
Console.WriteLine("Box : {0} ", fieldFacade.Box)
Console.WriteLine("Caption : {0} ", fieldFacade.Caption)
Console.WriteLine("Font Name : {0} ", fieldFacade.Font)
Console.WriteLine("Font Size : {0} ", fieldFacade.FontSize)
Console.WriteLine("Page Number : {0} ", fieldFacade.PageNumber)
Console.WriteLine("Text Color : {0} ", fieldFacade.TextColor)
Console.WriteLine("Text Encoding : {0} ", fieldFacade.TextEncoding)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim form As New Aspose.Pdf.Facades.Form()
' Open Document
form.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Open fdf file.
Dim fdfInputStream As System.IO.FileStream = New FileStream(dataDir & Convert.ToString("student.fdf"), FileMode.Open)
' Import data
form.ImportFdf(fdfInputStream)
' Close file stream
fdfInputStream.Close()
' Save updated document
form.Save(dataDir & Convert.ToString("ImportDataFromPdf_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim form As New Aspose.Pdf.Facades.Form()
' Open Document
form.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Open xfdf file.
Dim xfdfInputStream As System.IO.FileStream = New FileStream("student1.xfdf", FileMode.Open)
' Import data
form.ImportXfdf(xfdfInputStream)
' Close file stream
xfdfInputStream.Close()
' Save updated document
form.Save(dataDir & Convert.ToString("ImportDataFromXFDF_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
' Open document
Dim form As New Aspose.Pdf.Facades.Form()
' Open xml file.
Dim xmlInputStream As System.IO.FileStream = New FileStream(dataDir & Convert.ToString("input.xml"), FileMode.Open)
' Import data
form.ImportXml(xmlInputStream)
' Close file stream
xmlInputStream.Close()
' Save updated document
form.Save(dataDir & Convert.ToString("ImportDataFromXML_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim formEditor As New FormEditor()
' Open Document
formEditor.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Move field to new location
formEditor.MoveField("textfield", 300, 300, 400, 400)
' Save updated file
formEditor.Save(dataDir & Convert.ToString("MoveFormField_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim form As New FormEditor()
' Open the document and create a FormEditor object
form.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Set JavaScript
form.SetFieldScript("pushbutton", "app.alert(' Hello World!');")
' Save update document
form.Save(dataDir & Convert.ToString("SetJSPushButton_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Forms()
Dim form As New FormEditor()
' Open the document and create a FormEditor object
form.BindPdf(dataDir & Convert.ToString("input.pdf"))
' Set submit URL
form.SetSubmitUrl("submitbutton", "http://www.aspose.com")
' Save update document
form.Save(dataDir & Convert.ToString("SetSubmitButtonURL_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Open document
Dim mender As New PdfFileMend()
' Create PdfFileMend object to add text
mender.BindPdf(dataDir & Convert.ToString("AddImage.pdf"))
' Add image in the PDF file
mender.AddImage(dataDir & Convert.ToString("aspose-logo.jpg"), 1, 100, 600, 200, 700)
' Save changes
mender.Save(dataDir & Convert.ToString("AddImage_out_.pdf"))
' Close PdfFileMend object
mender.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Instantiate PdfPageEditor class to get particular page region
Dim editor As New Aspose.Pdf.Facades.PdfPageEditor()
' Bind the source PDF file
editor.BindPdf(dataDir & Convert.ToString("Convert-PageRegion.pdf"))
' Move the origin of PDF file to particular point
editor.MovePosition(0, 700)
' Create a memory stream object
Dim ms As New MemoryStream()
' Save the updated document to stream object
editor.Save(ms)
' Create PdfConverter object
Dim objConverter As New PdfConverter()
' Bind input pdf file
objConverter.BindPdf(ms)
' Set StartPage and EndPage properties to the page number to
' You want to convert images from
objConverter.StartPage = 1
objConverter.EndPage = 1
' Counter
Dim page As Integer = 1
' Initialize the converting process
objConverter.DoConvert()
' Check if pages exist and then convert to image one by one
While objConverter.HasNextImage()
objConverter.GetNextImage((dataDir & Convert.ToString("Specific_Region-Image")) + System.Math.Max(System.Threading.Interlocked.Increment(page), page - 1).ToString() + "_out_.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
End While
' Close the PdfConverter object
objConverter.Close()
' Close MemoryStream object holding the updated document
ms.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Create PdfConverter object
Dim objConverter As New PdfConverter()
' Bind input pdf file
objConverter.BindPdf(dataDir & Convert.ToString("ConvertPDFPages.pdf"))
' Initialize the converting process
objConverter.DoConvert()
objConverter.CoordinateType = PageCoordinateType.CropBox
' Check if pages exist and then convert to image one by one
While objConverter.HasNextImage()
objConverter.GetNextImage((dataDir & DateTime.Now.Ticks.ToString()) + "_out_.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
End While
' Close the PdfConverter object
objConverter.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Create PdfConverter object and bind input PDF file
Dim pdfConverter As New PdfConverter()
' Bind the source PDF file
pdfConverter.BindPdf(dataDir & Convert.ToString("ConvertToTIFF-Settings.pdf"))
' Start the conversion process
pdfConverter.DoConvert()
' Convert to TIFF image
pdfConverter.SaveAsTIFF(dataDir & Convert.ToString("output_out_.tif"))
' Close Converter object
pdfConverter.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Create PdfConverter object and bind input PDF file
Dim pdfConverter As New PdfConverter()
' Create Resolution object with 300 as an argument
Dim resolution As New Aspose.Pdf.Devices.Resolution(300)
' Specify the resolution value for PdfConverter object
pdfConverter.Resolution = resolution
' Bind the source PDF file
pdfConverter.BindPdf(dataDir & Convert.ToString("ConvertToTIFF-Settings.pdf"))
' Start the conversion process
pdfConverter.DoConvert()
' Create TiffSettings object and set ColorDepth
Dim tiffSettings As New TiffSettings()
tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp
' Convert to TIFF image
pdfConverter.SaveAsTIFF(dataDir & Convert.ToString("output_out_.tif"), 300, 300, tiffSettings)
' Close Converter object
pdfConverter.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Open PDF file
Dim contentEditor As New PdfContentEditor()
contentEditor.BindPdf(dataDir & Convert.ToString("DeleteAllImages.pdf"))
' Delete the images from the particular page
contentEditor.DeleteImage()
' Save output PDF
contentEditor.Save(dataDir & Convert.ToString("DeleteAllImages_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Open PDF file
Dim contentEditor As New PdfContentEditor()
contentEditor.BindPdf(dataDir & Convert.ToString("DeleteImages-Page.pdf"))
' Array of images to be deleted
Dim imageIndex As Integer() = New Integer() {1}
' Delete the images from the particular page
contentEditor.DeleteImage(2, imageIndex)
' Save output PDF
contentEditor.Save(dataDir & Convert.ToString("DeleteImages-Page_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Open input PDF
Dim extractor As New PdfExtractor()
extractor.BindPdf(dataDir & Convert.ToString("ExtractImageExtractionMode.pdf"))
' Specify Image Extraction Mode
extractor.ExtractImageMode = ExtractImageMode.DefinedInResources
' Extract Images based on Image Extraction Mode
extractor.ExtractImage()
' Get all the extracted images
While extractor.HasNextImage()
extractor.GetNextImage((dataDir & DateTime.Now.Ticks.ToString()) + "_out_.png", System.Drawing.Imaging.ImageFormat.Png)
End While
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Open input PDF
Dim pdfExtractor As New PdfExtractor()
pdfExtractor.BindPdf(dataDir & Convert.ToString("ExtractImages.pdf"))
' Extract all the images
pdfExtractor.ExtractImage()
' Get all the extracted images
While pdfExtractor.HasNextImage()
pdfExtractor.GetNextImage((dataDir & DateTime.Now.Ticks.ToString()) + "_out_.jpg")
End While
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Open input PDF
Dim pdfExtractor As New PdfExtractor()
pdfExtractor.BindPdf(dataDir & Convert.ToString("ExtractImages-Page.pdf"))
' Set StartPage and EndPage properties to the page number to
' You want to extract images from
pdfExtractor.StartPage = 2
pdfExtractor.EndPage = 2
' Extract images
pdfExtractor.ExtractImage()
' Get extracted images
While pdfExtractor.HasNextImage()
' Read image into memory stream
Dim memoryStream As New MemoryStream()
pdfExtractor.GetNextImage(memoryStream)
' Write to disk, if you like, or use it otherwise.
Dim fileStream As New FileStream((dataDir & DateTime.Now.Ticks.ToString()) + "_out_.jpg", FileMode.Create)
memoryStream.WriteTo(fileStream)
fileStream.Close()
End While
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Open input PDF
Dim pdfExtractor As New PdfExtractor()
pdfExtractor.BindPdf(dataDir & Convert.ToString("ExtractImages-Stream.pdf"))
' Extract images
pdfExtractor.ExtractImage()
' Get all the extracted images
While pdfExtractor.HasNextImage()
' Read image into memory stream
Dim memoryStream As New MemoryStream()
pdfExtractor.GetNextImage(memoryStream)
' Write to disk, if you like, or use it otherwise.
Dim fileStream As New FileStream((dataDir & DateTime.Now.Ticks.ToString()) + "_out_.jpg", FileMode.Create)
memoryStream.WriteTo(fileStream)
fileStream.Close()
End While
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Images()
' Open input PDF
Dim pdfContentEditor As New PdfContentEditor()
pdfContentEditor.BindPdf(dataDir & Convert.ToString("ReplaceImage.pdf"))
' Replace image on a particular page
pdfContentEditor.ReplaceImage(1, 1, dataDir & Convert.ToString("aspose-logo.jpg"))
' Save output PDF
pdfContentEditor.Save(dataDir & Convert.ToString("ReplaceImage_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Array of files
Dim portFiles As String() = New String(1) {}
portFiles(0) = dataDir & Convert.ToString("input.pdf")
portFiles(1) = dataDir & Convert.ToString("input2.pdf")
' Append file
pdfEditor.Append(dataDir & Convert.ToString("input3.pdf"), portFiles, 1, 1, dataDir & Convert.ToString("AppendArrayOfFiles_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Input and output stream
Dim inputStream As New FileStream(dataDir & Convert.ToString("inputvb.pdf"), FileMode.Open)
Dim outputStream As New FileStream(dataDir & Convert.ToString("AppendArrayOfFilesUsingStream_out_.pdf"), FileMode.Create)
' Srray of streams
Dim portStreams As FileStream() = New FileStream(1) {}
portStreams(0) = New FileStream(dataDir & Convert.ToString("input2vb.pdf"), FileMode.Open)
portStreams(1) = New FileStream(dataDir & Convert.ToString("input3vb.pdf"), FileMode.Open)
' Append file
pdfEditor.Append(inputStream, portStreams, 1, 1, outputStream)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Append file
pdfEditor.Append(dataDir & Convert.ToString("input.pdf"), dataDir & Convert.ToString("input2.pdf"), 1, 1, dataDir & Convert.ToString("AppendFiles_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Create streams
Dim inputStream As New FileStream(dataDir & Convert.ToString("input.pdf"), FileMode.Open)
Dim portStream As New FileStream(dataDir & Convert.ToString("input2.pdf"), FileMode.Open)
Dim outputStream As New FileStream(dataDir & Convert.ToString("AppendFilesUsingStreams_out_.pdf"), FileMode.Create)
' Append file
pdfEditor.Append(inputStream, portStream, 1, 1, outputStream)
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Array of files
Dim filesArray As String() = New String(1) {}
filesArray(0) = dataDir & Convert.ToString("input.pdf")
filesArray(1) = dataDir & Convert.ToString("input2.pdf")
' Concatenate files
pdfEditor.Concatenate(filesArray, dataDir & Convert.ToString("ConcatenateArrayOfFilesWithPath_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
Dim pfe As New Aspose.Pdf.Facades.PdfFileEditor()
pfe.CorruptedFileAction = Aspose.Pdf.Facades.PdfFileEditor.ConcatenateCorruptedFileAction.ConcatenateIgnoringCorrupted
pfe.Concatenate(New String() {dataDir & Convert.ToString("input.pdf"), dataDir & Convert.ToString("input2.pdf"), dataDir & Convert.ToString("input3.pdf")}, dataDir & Convert.ToString("CorruptedFiles_out_.pdf"))
If pfe.CorruptedItems.Length > 0 Then
Console.WriteLine("Corrupted documents:")
For Each item As Aspose.Pdf.Facades.PdfFileEditor.CorruptedItem In pfe.CorruptedItems
Console.WriteLine(item.Index.ToString() + " reason " + item.Exception.Message)
Next
Else
Console.WriteLine("No corrupted documents")
End If
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Array of files
Dim filesArray As String() = New String(1) {}
filesArray(0) = dataDir & Convert.ToString("input.pdf")
filesArray(1) = dataDir & Convert.ToString("input2.pdf")
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Display the resultant concatenated PDF file in
pdfEditor.Concatenate(filesArray, dataDir & Convert.ToString("RenderInBrowser_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Output stream
Dim outputStream As New FileStream(dataDir & Convert.ToString("ConcatenateArrayOfPdfUsingStreams_out_.pdf"), FileMode.Create)
' Array of streams
Dim inputStreams As FileStream() = New FileStream(1) {}
inputStreams(0) = New FileStream(dataDir & Convert.ToString("test.pdf"), FileMode.Open)
inputStreams(1) = New FileStream(dataDir & Convert.ToString("input5.pdf"), FileMode.Open)
' Concatenate file
pdfEditor.Concatenate(inputStreams, outputStream)
inputStreams(0).Flush()
inputStreams(0).Close()
inputStreams(1).Flush()
inputStreams(1).Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Create streams
Dim inputStream1 As New FileStream(dataDir & Convert.ToString("test.pdf"), FileMode.Open)
Dim inputStream2 As New FileStream(dataDir & Convert.ToString("input5.pdf"), FileMode.Open)
Dim blankStream As New FileStream(dataDir & Convert.ToString("blank.pdf"), FileMode.Open)
Dim outputStream As New FileStream(dataDir & Convert.ToString("ConcatenateBlankPdfUsingStreams_out_.pdf"), FileMode.Create)
' Concatenate file
pdfEditor.Concatenate(inputStream1, inputStream2, blankStream, outputStream)
inputStream1.Flush()
inputStream2.Flush()
blankStream.Flush()
inputStream1.Close()
inputStream2.Close()
blankStream.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Concatenate files
pdfEditor.Concatenate(dataDir & Convert.ToString("input.pdf"), dataDir & Convert.ToString("input2.pdf"), dataDir & Convert.ToString("ConcatenateUsingPath_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
Dim pfe As New PdfFileEditor()
Dim files As String() = Directory.GetFiles(dataDir)
pfe.CopyOutlines = False
pfe.Concatenate(files, dataDir & Convert.ToString("CopyOutline_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
Dim fileInputStream1 As New FileStream(dataDir & Convert.ToString("input.pdf"), FileMode.Open, FileAccess.Read)
Dim fileInputStream2 As New FileStream(dataDir & Convert.ToString("input2.pdf"), FileMode.Open, FileAccess.Read)
Dim fileOutputStream As New FileStream(dataDir & Convert.ToString("ConcatenateTaggedFiles_out_.pdf"), FileMode.Create, FileAccess.Write)
' Concatenate files
Dim editor As New PdfFileEditor()
editor.CopyLogicalStructure = True
Dim success As Boolean = editor.Concatenate(fileInputStream1, fileInputStream2, fileOutputStream)
Console.Out.WriteLine("Successful... " + success.ToString())
' Close the streams
fileOutputStream.Close()
fileInputStream1.Close()
fileInputStream2.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Output stream
Dim outputStream As New FileStream(dataDir & Convert.ToString("ConcatenateUsingStreams_out_.pdf"), FileMode.Create)
' Input streams
Dim inputStream1 As New FileStream(dataDir & Convert.ToString("test.pdf"), FileMode.Open)
Dim inputStream2 As New FileStream(dataDir & Convert.ToString("input5.pdf"), FileMode.Open)
' Concatenate file
pdfEditor.Concatenate(inputStream1, inputStream2, outputStream)
inputStream1.Flush()
inputStream2.Flush()
inputStream1.Close()
inputStream2.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Concatenate files
pdfEditor.Concatenate(dataDir & Convert.ToString("input.pdf"), dataDir & Convert.ToString("input2.pdf"), dataDir & Convert.ToString("blank.pdf"), dataDir & Convert.ToString("ConcatenateWithBlankPdf_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Array of pages to delete
Dim pagesToDelete As Integer() = New Integer() {1, 2}
' Delete pages
pdfEditor.Delete(dataDir & Convert.ToString("input.pdf"), pagesToDelete, dataDir & Convert.ToString("DeletePagesUsingFilePath_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Create streams
Dim inputStream As New FileStream(dataDir & Convert.ToString("test.pdf"), FileMode.Open)
Dim outputStream As New FileStream(dataDir & Convert.ToString("DeletePagesUsingStream_out_.pdf"), FileMode.Create)
' Array of pages to delete
Dim pagesToDelete As Integer() = New Integer() {1, 3}
' Delete pages
pdfEditor.Delete(inputStream, pagesToDelete, outputStream)
inputStream.Flush()
inputStream.Close()
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
Dim pagesToExtract As Integer() = New Integer() {1, 2}
' Extract pages
pdfEditor.Extract(dataDir & Convert.ToString("Extract.pdf"), pagesToExtract, dataDir & Convert.ToString("ExtractArrayOfPages_out_.pdf"))
' For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
' The path to the documents directory.
Dim dataDir As String = RunExamples.GetDataDir_AsposePdfFacades_Pages()
' Create PdfFileEditor object
Dim pdfEditor As New PdfFileEditor()
' Create streams
Dim inputStream As New FileStream(dataDir & Convert.ToString("MultiplePagesvb.pdf"), FileMode.Open)
Dim outputStream As New FileStream(dataDir & Convert.ToString("ExtractArrayOfPagesUsingStreams_out_.pdf"), FileMode.Create)
Dim pagesToExtract As Integer() = New Integer() {1, 2}
' Extract pages
pdfEditor.Extract(inputStream, pagesToExtract, outputStream)
inputStream.Flush()
inputStream.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment