Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Аннотации в PDF-документе содержатся в коллекции аннотаций объекта Page. Эта коллекция содержит все аннотации только для этой отдельной страницы: каждая страница имеет свою собственную коллекцию аннотаций. Чтобы добавить аннотацию на определенную страницу, добавьте ее в коллекцию аннотаций этой страницы с помощью метода Add.
Используйте класс ScreenAnnotation в пространстве имен Aspose.PDF.InteractiveFeatures.Annotations, чтобы включить файлы SWF в качестве аннотаций в PDF-документ. Аннотация экрана указывает область страницы, на которой могут воспроизводиться медиафайлы.
Когда вам нужно добавить внешнюю видеоссылку в PDF-документ, вы можете использовать MovieAnnotaiton. Аннотация фильма содержит анимационную графику и звук, которые будут представлены на экране компьютера и через динамики.
Sound Annotation аналогична текстовой аннотации, за исключением того, что вместо текстовой заметки она содержит звук, записанный с микрофона компьютера или импортированный из файла. Когда аннотация активируется, звук воспроизводится. Аннотация ведет себя как текстовая аннотация во многих отношениях, с другим значком (по умолчанию, динамик), чтобы указать, что она представляет звук.
Однако, когда требуется встроить медиа в PDF-документ, вам нужно использовать RichMediaAnnotation.
Следующие методы/свойства класса RichMediaAnnotation могут быть использованы.
Следующий фрагмент кода также работает с библиотекой Aspose.PDF.Drawing.
Следующий фрагмент кода показывает, как добавить аннотацию экрана в PDF-файл:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddScreenAnnotationWithMedia()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
// Open PDF document
using (cument = new Aspose.Pdf.Document(dataDir + "sample.pdf"))
{
// Path to the media file (SWF)
var mediaFile = dataDir + "input.swf";
// Create Screen Annotation
var screenAnnotation = new Aspose.Pdf.Annotations.ScreenAnnotation(
document.Pages[1],
new Aspose.Pdf.Rectangle(170, 190, 470, 380),
mediaFile);
// Add the annotation to the page
document.Pages[1].Annotations.Add(screenAnnotation);
// Save PDF document
document.Save(dataDir + "AddScreenAnnotationWithMedia_out.pdf");
}
}
Следующий фрагмент кода показывает, как добавить аннотацию звука в PDF-файл:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddSoundAnnotation()
{
// Open PDF document
var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
using (var document = new Aspose.Pdf.Document(dataDir + "sample.pdf"))
{
var mediaFile = dataDir + "file_example_WAV_1MG.wav";
// Create Sound Annotation
var soundAnnotation = new Aspose.Pdf.Annotations.SoundAnnotation(
document.Pages[1],
new Aspose.Pdf.Rectangle(20, 700, 60, 740),
mediaFile)
{
Color = Aspose.Pdf.Color.Blue,
Title = "John Smith",
Subject = "Sound Annotation demo",
Popup = new Aspose.Pdf.Annotations.PopupAnnotation(document.Pages[1], new Aspose.Pdf.Rectangle(20, 700, 60, 740))
};
document.Pages[1].Annotations.Add(soundAnnotation);
// Save PDF document
document.Save(dataDir + "AddSoundAnnotation_out.pdf");
}
}
Следующий фрагмент кода показывает, как добавить RichMediaAnnotation в PDF-файл:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddRichMediaAnnotation()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
// Create PDF document
using (var document = new Aspose.Pdf.Document())
{
var pathToAdobeApp = @"C:\Program Files (x86)\Adobe\Acrobat 2017\Acrobat\Multimedia Skins";
Page page = document.Pages.Add();
// Define video and poster names
const string videoName = "file_example_MP4_480_1_5MG.mp4";
const string posterName = "file_example_MP4_480_1_5MG_poster.jpg";
string skinName = "SkinOverAllNoFullNoCaption.swf";
// Create RichMediaAnnotation
var rma = new RichMediaAnnotation(page, new Aspose.Pdf.Rectangle(100, 500, 300, 600));
// Specify the stream containing the video player code
rma.CustomPlayer = new FileStream(Path.Combine(pathToAdobeApp, "Players", "Videoplayer.swf"), FileMode.Open, FileAccess.Read);
// Compose flash variables line for the player
rma.CustomFlashVariables = $"source={videoName}&skin={skinName}";
// Add skin code
rma.AddCustomData(skinName, new FileStream(Path.Combine(pathToAdobeApp, skinName), FileMode.Open, FileAccess.Read));
// Set poster for the video
rma.SetPoster(new FileStream(Path.Combine(dataDir, posterName), FileMode.Open, FileAccess.Read));
// Set video content
using (Stream fs = new FileStream(Path.Combine(dataDir, videoName), FileMode.Open, FileAccess.Read))
{
rma.SetContent(videoName, fs);
}
// Set type of the content (video)
rma.Type = RichMediaAnnotation.ContentType.Video;
// Activate player by click
rma.ActivateOn = RichMediaAnnotation.ActivationEvent.Click;
// Update annotation data
rma.Update();
// Add annotation to the page
page.Annotations.Add(rma);
// Save PDF document
document.Save(dataDir + "RichMediaAnnotation_out.pdf");
}
}
Пожалуйста, попробуйте использовать следующий фрагмент кода, чтобы получить MultimediaAnnotation из PDF-документа.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetMultimediaAnnotation()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "RichMediaAnnotation.pdf"))
{
// Get multimedia annotations (Screen, Sound, RichMedia)
var mediaAnnotations = document.Pages[1].Annotations
.Where(a => a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.Screen
|| a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.Sound
|| a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.RichMedia)
.Cast<Aspose.Pdf.Annotations.Annotation>();
// Iterate through the annotations and print their details
foreach (var ma in mediaAnnotations)
{
Console.WriteLine($"{ma.AnnotationType} [{ma.Rect}]");
}
}
}
Следующий фрагмент кода показывает, как удалить MultimediaAnnotation из PDF-файла.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DeletePolyAnnotation()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "RichMediaAnnotation.pdf"))
{
// Get RichMedia annotations
var richMediaAnnotations = document.Pages[1].Annotations
.Where(a => a.AnnotationType == Aspose.Pdf.Annotations.AnnotationType.RichMedia)
.Cast<Aspose.Pdf.Annotations.RichMediaAnnotation>();
// Delete each RichMedia annotation
foreach (var rma in richMediaAnnotations)
{
document.Pages[1].Annotations.Delete(rma);
}
// Save PDF document
document.Save(dataDir + "DeletePolyAnnotation_out.pdf");
}
}
Интерактивные формы используют Widget Annotations для представления внешнего вида полей и управления взаимодействиями с пользователем. Мы используем эти элементы формы, которые добавляются в PDF, чтобы упростить ввод, отправку информации или выполнение других взаимодействий с пользователем.
Аннотации виджетов являются графическим представлением поля формы на конкретных страницах, поэтому мы не можем создать их напрямую как аннотацию.
Каждая аннотация виджета будет иметь соответствующую графику (внешний вид) в зависимости от ее типа. После создания определенные визуальные аспекты могут быть изменены, такие как стиль границы и цвет фона. Другие свойства, такие как цвет текста и шрифт, могут быть изменены через поле, как только оно будет прикреплено к нему.
В некоторых случаях вы можете захотеть, чтобы поле отображалось на более чем одной странице, повторяя одно и то же значение. В этом случае поля, которые обычно имеют только один виджет, могут иметь несколько прикрепленных виджетов: TextField, ListBox, ComboBox и CheckBox обычно имеют ровно один, в то время как RadioGroup имеет несколько виджетов, по одному для каждой радиокнопки. Кто-то, заполняющий форму, может использовать любой из этих виджетов для обновления значения поля, и это отражается во всех других виджетах.
Каждое поле формы для каждого места в документе представляет одну аннотацию виджета. Данные, специфичные для местоположения аннотации виджета, добавляются на конкретную страницу. Каждое поле формы имеет несколько вариантов. Кнопка может быть радиокнопкой, флажком или кнопкой.
В этом примере мы узнаем, как добавить кнопки для навигации в документе.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddPrintButton()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Create PDF document
using (var document = new Aspose.Pdf.Document())
{
// Add page
var page = document.Pages.Add();
// Define the rectangle for the button
var rect = new Aspose.Pdf.Rectangle(72, 748, 164, 768);
// Create a button field
var printButton = new Aspose.Pdf.Forms.ButtonField(page, rect)
{
AlternateName = "Print current document",
Color = Aspose.Pdf.Color.Black,
PartialName = "printBtn1",
NormalCaption = "Print Document"
};
// Set the border style for the button
var border = new Aspose.Pdf.Annotations.Border(printButton)
{
Style = Aspose.Pdf.Annotations.BorderStyle.Solid,
Width = 2
};
printButton.Border = border;
// Set the border and background color characteristics
printButton.Characteristics.Border = System.Drawing.Color.FromArgb(255, 0, 0, 255);
printButton.Characteristics.Background = System.Drawing.Color.FromArgb(255, 0, 191, 255);
// Add the button to the form
document.Form.Add(printButton);
// Save PDF document
document.Save(dataDir + "PrintButton_out.pdf");
}
}
Эта кнопка имеет границу и установленный фон. Также мы устанавливаем имя кнопки (Name), подсказку (AlternateName), метку (NormalCaption) и цвет текста метки (Color).
Существует более сложный пример использования аннотаций виджетов - навигация по документу PDF. Это может понадобиться для подготовки презентации PDF-документа.
Этот пример показывает, как создать 4 кнопки:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddNavigationButtons()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "JSON Fundamenals.pdf"))
{
// Create an array of button fields
var buttons = new Aspose.Pdf.Forms.ButtonField[4];
// Define alternate names and normal captions for the buttons
var alternateNames = new[] { "Go to first page", "Go to prev page", "Go to next page", "Go to last page" };
var normalCaptions = new[] { "First", "Prev", "Next", "Last" };
// Define predefined actions for the buttons
PredefinedAction[] actions = {
PredefinedAction.FirstPage,
PredefinedAction.PrevPage,
PredefinedAction.NextPage,
PredefinedAction.LastPage
};
// Define border and background colors
var clrBorder = System.Drawing.Color.FromArgb(255, 0, 255, 0);
var clrBackGround = System.Drawing.Color.FromArgb(255, 0, 96, 70);
// We should create the buttons without attaching them to the page.
for (var i = 0; i < 4; i++)
{
buttons[i] = new Aspose.Pdf.Forms.ButtonField(document, new Aspose.Pdf.Rectangle(32 + i * 80, 28, 104 + i * 80, 68))
{
AlternateName = alternateNames[i],
Color = Aspose.Pdf.Color.White,
NormalCaption = normalCaptions[i],
OnActivated = new Aspose.Pdf.Annotations.NamedAction(actions[i])
};
// Set the border style for the button
buttons[i].Border = new Aspose.Pdf.Annotations.Border(buttons[i])
{
Style = Aspose.Pdf.Annotations.BorderStyle.Solid,
Width = 2
};
// Set the border and background color characteristics
buttons[i].Characteristics.Border = clrBorder;
buttons[i].Characteristics.Background = clrBackGround;
}
// Duplicate the array of buttons on each page in the document
for (var pageIndex = 1; pageIndex <= document.Pages.Count; pageIndex++)
{
for (var i = 0; i < 4; i++)
{
document.Form.Add(buttons[i], $"btn{pageIndex}_{i + 1}", pageIndex);
}
}
// Save PDF document
document.Save(dataDir + "NavigationButtons_out.pdf");
// We call Form.Add method with the following parameters: field, name, and the index of the pages that this field will be added to.
// And to get the full result, we need disable the “First” and “Prev” buttons on the first page and the “Next” and “Last” buttons on the last page.
document.Form["btn1_1"].ReadOnly = true;
document.Form["btn1_2"].ReadOnly = true;
document.Form[$"btn{document.Pages.Count}_3"].ReadOnly = true;
document.Form[$"btn{document.Pages.Count}_4"].ReadOnly = true;
}
}
Для получения более подробной информации и возможностей этих функций смотрите также Работа с формами.
В PDF-документах вы можете просматривать и управлять высококачественным 3D-контентом, созданным с помощью 3D CAD или программного обеспечения для 3D-моделирования и встроенным в PDF-документ. Можно вращать 3D-элементы во всех направлениях, как если бы вы держали их в руках.
Зачем вообще нужен 3D-дисплей изображений?
За последние несколько лет технологии достигли огромных прорывов во всех областях благодаря 3D-печати. Технологии 3D-печати могут быть применены для обучения технологическим навыкам в строительстве, машиностроении, дизайне как основному инструменту. Эти технологии благодаря появлению персональных печатающих устройств могут способствовать внедрению новых форм организации образовательного процесса, повышению мотивации и формированию необходимых компетенций выпускников и преподавателей.
Основная задача 3D-моделирования - это идея будущего объекта или предмета, потому что для того, чтобы выпустить объект, необходимо понимание его конструктивных особенностей во всех деталях для последующей регенерации в промышленном дизайне или архитектуре.
3D-аннотация добавляется с использованием модели, созданной в формате U3D.
Создайте новый Document.
Загрузите данные желаемой 3D-модели (в нашем случае “Ring.u3d”) для создания PDF3DContent.
Создайте объект 3dArtWork и свяжите его с документом и 3DContent.
Настройте объект pdf3dArtWork:
CAD
)Solid
)ViewArray
, создайте как минимум один 3D View и добавьте его в массив.Установите 3 основных параметра в аннотации:
page
, на которой будет размещена аннотация.rectangle
, внутри которого будет аннотация.3dArtWork
.Для лучшего представления 3D-объекта установите рамку границы.
Установите вид по умолчанию (например - TOP).
Добавьте некоторые дополнительные параметры: имя, предварительный постер и т.д.
Добавьте аннотацию на Page.
Сохраните результат.
Пожалуйста, проверьте следующий фрагмент кода для добавления 3D-аннотации.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void Add3dAnnotation()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();
// Create PDF document
using (var document = new Aspose.Pdf.Document())
{
// Load 3D content
var pdf3DContent = new Aspose.Pdf.Annotations.PDF3DContent(dataDir + "Ring.u3d");
// Create 3D artwork
var pdf3dArtWork = new Aspose.Pdf.Annotations.PDF3DArtwork(document, pdf3DContent)
{
LightingScheme = new Aspose.Pdf.Annotations.PDF3DLightingScheme(Aspose.Pdf.Annotations.LightingSchemeType.CAD),
RenderMode = new Aspose.Pdf.Annotations.PDF3DRenderMode(Aspose.Pdf.Annotations.RenderModeType.Solid),
};
// Define matrices for different views
var topMatrix = new Aspose.Pdf.Matrix3D(1, 0, 0, 0, -1, 0, 0, 0, -1, 0.10271, 0.08184, 0.273836);
var frontMatrix = new Aspose.Pdf.Matrix3D(0, -1, 0, 0, 0, 1, -1, 0, 0, 0.332652, 0.08184, 0.085273);
// Add views to the 3D artwork
pdf3dArtWork.ViewArray.Add(new Aspose.Pdf.Annotations.PDF3DView(document, topMatrix, 0.188563, "Top")); //1
pdf3dArtWork.ViewArray.Add(new Aspose.Pdf.Annotations.PDF3DView(document, frontMatrix, 0.188563, "Left")); //2
// Add page
var page = document.Pages.Add();
// Create a 3D annotation
var pdf3dAnnotation = new Aspose.Pdf.Annotations.PDF3DAnnotation(page, new Aspose.Pdf.Rectangle(100, 500, 300, 700), pdf3dArtWork);
pdf3dAnnotation.Border = new Aspose.Pdf.Annotations.Border(pdf3dAnnotation);
pdf3dAnnotation.SetDefaultViewIndex(1);
pdf3dAnnotation.Flags = Aspose.Pdf.Annotations.AnnotationFlags.NoZoom;
pdf3dAnnotation.Name = "Ring.u3d";
// Set preview image if needed
// pdf3dAnnotation.SetImagePreview(dataDir + "sample_3d.png");
// Add the 3D annotation to the page
document.Pages[1].Annotations.Add(pdf3dAnnotation);
// Save PDF document
document.Save(dataDir + "Add3dAnnotation_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.