diff --git a/knowledge-base/create-dashed-line-border-table-radpdfprocessing.md b/knowledge-base/create-dashed-line-border-table-radpdfprocessing.md index 7ac95c7d..87522c1f 100644 --- a/knowledge-base/create-dashed-line-border-table-radpdfprocessing.md +++ b/knowledge-base/create-dashed-line-border-table-radpdfprocessing.md @@ -76,11 +76,13 @@ Please note that you can modify the `Borders` property of the `DefaultCellProper table.DefaultCellProperties.Borders = new TableCellBorders(null, null, null,b); ``` +>note As of **Q3 2024** RadPdfProcessing offers *Dotted*, *Dashed*, and *DashSmallGap* [border styles]({%slug radpdfprocessing-editing-table%}) out-of-the-box without the necessity to play with the **StrokeDashArray** of the **FixedContentEditor**. With this update, the Dotted, Dashed, DashSmallGap, and Thick border lines are now exported from [RadFlowDocument]({%slug radwordsprocessing-model-radflowdocument%}) to [RadFixedDocument]({%slug radpdfprocessing-model-radfixeddocument%}) as well. + ## See Also * [TableCell]({%slug radpdfprocessing-editing-tablecell%}) * [Table]({%slug radpdfprocessing-editing-table%}) -* [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%}}) -* [Create Repeating Table Header Row in PdfProcessing]({%slug pdfprocessing-create-repeat-header-row%}) +* [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%}) +* [Supported Border Styles]({%slug radpdfprocessing-editing-table%}) diff --git a/libraries/radpdfprocessing/editing/images/pdf-dash-small-gap-border.png b/libraries/radpdfprocessing/editing/images/pdf-dash-small-gap-border.png new file mode 100644 index 00000000..3479a3e9 Binary files /dev/null and b/libraries/radpdfprocessing/editing/images/pdf-dash-small-gap-border.png differ diff --git a/libraries/radpdfprocessing/editing/images/pdf-dashed-border.png b/libraries/radpdfprocessing/editing/images/pdf-dashed-border.png new file mode 100644 index 00000000..e5701888 Binary files /dev/null and b/libraries/radpdfprocessing/editing/images/pdf-dashed-border.png differ diff --git a/libraries/radpdfprocessing/editing/images/pdf-dotted-border.png b/libraries/radpdfprocessing/editing/images/pdf-dotted-border.png new file mode 100644 index 00000000..5181d09f Binary files /dev/null and b/libraries/radpdfprocessing/editing/images/pdf-dotted-border.png differ diff --git a/libraries/radpdfprocessing/editing/images/pdf-single-border.png b/libraries/radpdfprocessing/editing/images/pdf-single-border.png new file mode 100644 index 00000000..98d25524 Binary files /dev/null and b/libraries/radpdfprocessing/editing/images/pdf-single-border.png differ diff --git a/libraries/radpdfprocessing/editing/table.md b/libraries/radpdfprocessing/editing/table.md index f7142d19..6323e1e2 100644 --- a/libraries/radpdfprocessing/editing/table.md +++ b/libraries/radpdfprocessing/editing/table.md @@ -9,14 +9,11 @@ position: 3 # Table - - -The __Table__ class helps you easily create tabular data content. All you need to do is define the table content and pass a Table instance to a [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%}) or a [RadFixedDocumentEditor]({%slug radpdfprocessing-editing-radfixeddocumenteditor%}). From then on, these editors are responsible for positioning, measuring, drawing and splitting the table onto pages. +The **Table** class helps you easily create tabular data content. All you need to do is define the table content and pass a Table instance to a [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%}) or a [RadFixedDocumentEditor]({%slug radpdfprocessing-editing-radfixeddocumenteditor%}). From then on, these editors are responsible for positioning, measuring, drawing and splitting the table onto pages. ![Rad Pdf Processing Editing Table 01](images/RadPdfProcessing_Editing_Table_01.png) -This article aims to present the table-related API in __RadPdfProcessing__. It contains the following sections: - +This article aims to present the table-related API in __RadPdfProcessing__. It contains the following sections: * [Defining Table Content](#defining-table-content) @@ -279,6 +276,17 @@ As a result, on __Figure 7__ you can see a 45-degree rotated table similar to th #### Figure 7: FixedWidth table ![Rad Pdf Processing Editing Table 08](images/RadPdfProcessing_Editing_Table_08.png) +## Supported Border Styles + +As of **Q3 2024**, along with the BorderStyle.*Single*, RadPdfProcessing offers *Dotted*, *Dashed*, and *DashSmallGap* border styles. With this update, the Dotted, Dashed, DashSmallGap, and Thick border lines are now exported from [RadFlowDocument]({%slug radwordsprocessing-model-radflowdocument%}) to [RadFixedDocument]({%slug radpdfprocessing-model-radfixeddocument%}) as well. + +|BorderStyle|Border Design| +|----|----| +|Single|![Pdf Single Border](images/pdf-single-border.png)| +|Dotted|![Pdf Dotted Border](images/pdf-dotted-border.png)| +|Dashed|![Pdf Dashed Border](images/pdf-dashed-border.png)| +|DashSmallGap|![Pdf Single Border](images/pdf-dash-small-gap-border.png)| + ## See Also * [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%}) diff --git a/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-highlight-annotation-with-appearance.gif b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-highlight-annotation-with-appearance.gif new file mode 100644 index 00000000..a76d6d67 Binary files /dev/null and b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-highlight-annotation-with-appearance.gif differ diff --git a/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-highlight-annotation.png b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-highlight-annotation.png new file mode 100644 index 00000000..54c4e757 Binary files /dev/null and b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-highlight-annotation.png differ diff --git a/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-squiggly-annotation.png b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-squiggly-annotation.png new file mode 100644 index 00000000..8e67064b Binary files /dev/null and b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-squiggly-annotation.png differ diff --git a/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-strikeOut-annotation.png b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-strikeOut-annotation.png new file mode 100644 index 00000000..1aa8e10c Binary files /dev/null and b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-strikeOut-annotation.png differ diff --git a/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-text-markup-annotation.png b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-text-markup-annotation.png new file mode 100644 index 00000000..d16d2027 Binary files /dev/null and b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-text-markup-annotation.png differ diff --git a/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-textannotation-with-appearance.gif b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-textannotation-with-appearance.gif new file mode 100644 index 00000000..d20c5776 Binary files /dev/null and b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-textannotation-with-appearance.gif differ diff --git a/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-textannotation-with-popup.png b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-textannotation-with-popup.png new file mode 100644 index 00000000..e3e1320e Binary files /dev/null and b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-textannotation-with-popup.png differ diff --git a/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-textannotation.png b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-textannotation.png new file mode 100644 index 00000000..4f9ed769 Binary files /dev/null and b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-textannotation.png differ diff --git a/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-underline-annotation.png b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-underline-annotation.png new file mode 100644 index 00000000..9a7a7949 Binary files /dev/null and b/libraries/radpdfprocessing/model/annotations/images/pdf-processing-create-underline-annotation.png differ diff --git a/libraries/radpdfprocessing/model/annotations/links.md b/libraries/radpdfprocessing/model/annotations/links.md index 91e14313..018f0450 100644 --- a/libraries/radpdfprocessing/model/annotations/links.md +++ b/libraries/radpdfprocessing/model/annotations/links.md @@ -1,6 +1,7 @@ --- title: Links page_title: Links +description: Link annotations represent either a hypertext link to a destination elsewhere in the document or an action to be performed. slug: radpdfprocessing-model-annotations-links tags: annotations,overview,pdfprocessing,link,links published: True diff --git a/libraries/radpdfprocessing/model/annotations/overview.md b/libraries/radpdfprocessing/model/annotations/overview.md index 7cbec410..9b59dc05 100644 --- a/libraries/radpdfprocessing/model/annotations/overview.md +++ b/libraries/radpdfprocessing/model/annotations/overview.md @@ -1,6 +1,7 @@ --- title: Annotations Overview page_title: Annotations Overview +description: Learn what annotation types are supported in the PdfProcessing library offered by the Telerik Document Processing. slug: radpdfprocessing-model-annotations-overview tags: annotations,overview,pdfprocessing published: True @@ -9,11 +10,23 @@ position: 0 # Annotations Overview -The abstract __Annotation__ element associates an object with a location on a [RadFixedPage]({%slug radpdfprocessing-model-radfixedpage%}). Annotation exposes the following properties: +An *annotation* associates an object such as a note, sound, or movie with a location on a page of a PDF document, or provides a way to interact with the user by +means of the mouse and keyboard. PDF includes a wide variety of standard [annotation types](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Fixed.Model.Annotations.AnnotationType.html). Many of the standard annotation types may be displayed in either the open or the closed state. When closed, they appear on the page in some distinctive form, such as an icon, a box, or a rubber stamp, depending on the specific annotation type. When the user activates the annotation by clicking it, it exhibits its associated object, such as by opening a pop-up window displaying a text note or by playing a sound or a movie. + +The abstract **Annotation** element associates an object with a location on a [RadFixedPage]({%slug radpdfprocessing-model-radfixedpage%}). Annotation exposes the following properties: -* __Rect__: The rectangle, which defines the location of the annotation on the page. +* **Rect**: The rectangle, which defines the location of the annotation on the page. -* __Type__: Property of type [AnnotationType](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Fixed.Model.Annotations.AnnotationType.html), which determines the type of the annotation. The only supported types are [Link]({%slug radpdfprocessing-model-annotations-links%}) and [Widget]({%slug radpdfprocessing-model-annotations-widgets%}). +* **Type**: Property of type [AnnotationType](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Fixed.Model.Annotations.AnnotationType.html), which determines the type of the annotation. The supported types are listed in the following table: + +|Annotation Type|Description| +|----|----| +|[Link]({%slug radpdfprocessing-model-annotations-links%})|A link annotation represents either a hypertext link to a destination elsewhere in the document or an action to be performed.| +|[Widget]({%slug radpdfprocessing-model-annotations-widgets%})|Interactive forms use widget annotations to represent the appearance of fields and to manage user interactions.| +|[Text]({%slug radpdfprocessing-model-annotations-text%})|A text annotation represents a *sticky note* attached to a point in the PDF document.| +|Line|| +|Stamp|| +|[TextMarkup]({%slug radpdfprocessing-model-annotations-text-markup%})| Text markup annotations appear as **Highlights**, **Underlines**, **Strikeouts** or **Squiggly** underlines in the text of a document. When opened, they display a pop-up window containing the text of the associated note.| * **Border**: Represents the annotation borders. This property is of type [AnnotationBorder](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Fixed.Model.Annotations.AnnotationBorder.html). @@ -22,5 +35,6 @@ The abstract __Annotation__ element associates an object with a location on a [R ## See Also * [RadFixedPage]({%slug radpdfprocessing-model-radfixedpage%}) - * [AnnotationType API Reference](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Fixed.Model.Annotations.AnnotationType.html) - * [Link API Reference](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Fixed.Model.Annotations.Link.html) + * [TextMarkup]({%slug radpdfprocessing-model-annotations-text-markup%}) + * [Text]({%slug radpdfprocessing-model-annotations-text%}) + * [Link]({%slug radpdfprocessing-model-annotations-links%}) diff --git a/libraries/radpdfprocessing/model/annotations/text-markup.md b/libraries/radpdfprocessing/model/annotations/text-markup.md new file mode 100644 index 00000000..97c23479 --- /dev/null +++ b/libraries/radpdfprocessing/model/annotations/text-markup.md @@ -0,0 +1,174 @@ +--- +title: Text Markup +page_title: Text Markup Annotation +description: Text markup annotations appear as highlights, underlines, strikeouts, or squiggly underlines in the text of a document. +slug: radpdfprocessing-model-annotations-text-markup +tags: annotation, overview, pdfprocessing, text, markup +published: True +position: 4 +--- + +# TextMarkup + +**Text Markup annotations** appear as highlights, underlines, strikeouts, or jagged ("squiggly") underlines in the text of a document. When opened, they display a pop-up window containing the text of the associated note. + +![Text Markup Annotation](images/pdf-processing-create-text-markup-annotation.png) + +The **TextMarkupAnnotation** class is a derivative of the **MarkupAnnotation** (descendent of **ContentAnnotation**) and it exposes the following properties: + +|Property|Description| +|---|---| +|**TextMarkupType**|Gets the type of the annotation. The **TextMarkupAnnotationType** enum offers *Highlight*, *StrikeOut*, *Underline*, *Squiggly* options.| +|**Opacity**|Gets or sets the opacity of the annotation.| +|**Contents**|Gets or sets the text that shall be displayed for the annotation.| +|**Color**|Gets or sets the color of the annotation.| +|**Content**|Gets the source defining the visual content of the annotation. This content is with bigger priority compared to the annotation appearance characteristics and text properties and it is visualized by default when opening the exported document in some PDF viewer.| + +Depending on the TextMarkupAnnotationType the respective type of the TextMarkup annotation can be added to the PDF document using the below examples: + +## Highlight + +### Creating a Highlight Annotation + +```csharp + string sampleText = File.ReadAllText("dummyText.txt"); + + RadFixedDocument fixedDocument = new RadFixedDocument(); + using (RadFixedDocumentEditor documentEditor = new RadFixedDocumentEditor(fixedDocument)) + { + documentEditor.InsertRun(sampleText); + } + TextSearch search = new TextSearch(fixedDocument); + IEnumerable result = search.FindAll("amet", TextSearchOptions.Default); + foreach (SearchResult r in result) + { + Rect highlightRectangle = r.GetWordBoundingRect(); + TextMarkupAnnotation annotation = r.GetResultPage().Annotations.AddHighlight(highlightRectangle); + annotation.Color = new RgbColor(125, 255, 0, 0); + + annotation.RecalculateContent(); + } + +``` + +![Create Highlight Annotation](images/pdf-processing-create-highlight-annotation.png) + +### Creating a Highlight Annotation with Appearance + + +```csharp + private RadFixedDocument CreateTextMarkupAnnotation() + { + string sampleText = File.ReadAllText("dummyText.txt"); + RadFixedDocument fixedDocument = new RadFixedDocument(); + using (RadFixedDocumentEditor documentEditor = new RadFixedDocumentEditor(fixedDocument)) + { + documentEditor.InsertRun(sampleText); + } + TextMarkupAnnotation annotation = fixedDocument.Pages[0].Annotations.AddHighlight(new Rect(150, 150, 100, 40)); + + FormSource simpleForm = new FormSource(); + CreateContentFormWithText(simpleForm, "Hover me!"); + annotation.Content.NormalContentSource = simpleForm; + + FormSource secondForm = new FormSource(); + CreateContentFormWithText(secondForm, "Hovered!"); + annotation.Content.MouseOverContentSource = secondForm; + return fixedDocument; + } + + private static void CreateContentFormWithText(FormSource normalForm, string text) + { + Size s = new Size(100, 40); + Random rand= new Random(); + normalForm.Size = s; + + FixedContentEditor formEditor = new FixedContentEditor(normalForm); + + using (formEditor.SaveProperties()) + { + formEditor.GraphicProperties.IsFilled = true; + formEditor.GraphicProperties.IsStroked = true; + formEditor.GraphicProperties.StrokeThickness = 1; + formEditor.GraphicProperties.StrokeColor = new RgbColor(255, 0, 0); + formEditor.GraphicProperties.FillColor = new RgbColor(175,255, 255, 0); + formEditor.GraphicProperties.StrokeDashArray = new double[] { 17, 4 }; + formEditor.DrawRectangle(new Rect(s)); + } + + formEditor.TextProperties.FontSize = 16; + formEditor.Position.Translate(10, 10); + formEditor.DrawText(text); + } +``` + +![Create Highlight Annotation with Appearance](images/pdf-processing-create-highlight-annotation-with-appearance.gif) + +## Underline + +```csharp + RadFixedDocument fixedDocument = new RadFixedDocument(); + RadFixedPage page = fixedDocument.Pages.AddPage(); + FixedContentEditor editor = new FixedContentEditor(page); + editor.Position.Translate(100, 100); + editor.DrawText("This is an underline."); + + TextSearch search = new TextSearch(fixedDocument); + IEnumerable underlineSearch = search.FindAll("underline", TextSearchOptions.Default); + Rect underlineRectangle = underlineSearch.First().GetWordBoundingRect(); + TextMarkupAnnotation underlineAnnotation = page.Annotations.AddUnderline(underlineRectangle); + underlineAnnotation.Color = new RgbColor(255, 0, 255); + underlineAnnotation.Opacity = 0.90; + underlineAnnotation.RecalculateContent(); +``` + +![Create Underline Annotation](images/pdf-processing-create-underline-annotation.png) + +## Squiggly + +```csharp + RadFixedDocument fixedDocument = new RadFixedDocument(); + RadFixedPage page = fixedDocument.Pages.AddPage(); + FixedContentEditor editor = new FixedContentEditor(page); + editor.Position.Translate(100, 100); + editor.DrawText("This is a squiggly line."); + + TextSearch search = new TextSearch(fixedDocument); + IEnumerable squigglySearch = search.FindAll("squiggly", TextSearchOptions.Default); + Rect squigglyRectangle = squigglySearch.First().GetWordBoundingRect(); + TextMarkupAnnotation squigglyAnnotation = page.Annotations.AddSquiggly(squigglyRectangle); + squigglyAnnotation.Color = new RgbColor (255,0, 0); + squigglyAnnotation.Opacity = 0.70; + squigglyAnnotation.RecalculateContent(); +``` + +![Create Squiggly Annotation](images/pdf-processing-create-squiggly-annotation.png) + +## StrikeOut + +```csharp + RadFixedDocument fixedDocument = new RadFixedDocument(); + RadFixedPage page = fixedDocument.Pages.AddPage(); + FixedContentEditor editor = new FixedContentEditor(page); + editor.Position.Translate(100, 100); + editor.DrawText("This is an underline."); + + TextSearch search = new TextSearch(fixedDocument); + IEnumerable underlineSearch = search.FindAll("underline", TextSearchOptions.Default); + Rect underlineRectangle = underlineSearch.First().GetWordBoundingRect(); + TextMarkupAnnotation underlineAnnotation = page.Annotations.AddUnderline(underlineRectangle); + underlineAnnotation.Color = new RgbColor(255, 0, 255); + underlineAnnotation.Opacity = 0.90; + underlineAnnotation.RecalculateContent(); +``` + +![Create StrikeOut Annotation](images/pdf-processing-create-strikeOut-annotation.png) + + + +## See Also + +* [AcroForm]({%slug radpdfprocessing-model-interactive-forms-acroform %}) +* [FormField]({%slug radpdfprocessing-model-interactive-forms-form-fields%}) +* [Annotations Overview]({%slug radpdfprocessing-model-annotations-overview%}) +* [FormSource]({%slug radpdfprocessing-model-formsource%}) diff --git a/libraries/radpdfprocessing/model/annotations/text.md b/libraries/radpdfprocessing/model/annotations/text.md new file mode 100644 index 00000000..3ca083d4 --- /dev/null +++ b/libraries/radpdfprocessing/model/annotations/text.md @@ -0,0 +1,119 @@ +--- +title: Text +page_title: Text Annotation +description: Text annotations represents a sticky note attached to a point in the PDF document. +slug: radpdfprocessing-model-annotations-text +tags: annotation, overview, pdfprocessing, text +published: True +position: 3 +--- + +# Text Annotation + +A **Text annotation** represents a *sticky note* attached to a point in the PDF document. When closed, the annotation appears as an icon; when opened, it displays a pop-up window containing the text of the note in a font and size chosen by the viewer application. + +>note Text annotations do not scale and rotate with the page. They behave as if the NoZoom and NoRotate annotation flags were always set. + +The **TextAnnotation** class is a derivative of the **MarkupAnnotation** (descendent of **ContentAnnotation**) and it exposes the following properties: + +|Property|Description| +|---|---| +|**Opacity**|Gets or sets the opacity of the annotation.| +|**Contents**|Gets or sets the text that shall be displayed for the annotation.| +|**Color**|Gets or sets the color of the annotation.| +|**Content**|Gets the source defining the visual content of the annotation. This content is with bigger priority compared to the annotation appearance characteristics and text properties and it is visualized by default when opening the exported document in some PDF viewer.| + + +### Creating a TextAnnotation + +```csharp + string sampleText = "sample text here"; + RadFixedDocument fixedDocument = new RadFixedDocument(); + using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(fixedDocument)) + { + editor.InsertRun(sampleText); + } + RadFixedPage page = fixedDocument.Pages[0]; + TextAnnotation annotation = page.Annotations.AddText(new Rect(200, 100, 200, 200)); + annotation.Contents = "This is a TextAnnotation"; + annotation.Opacity = 0.5; + annotation.Color = new RgbColor(255, 0, 0); //Default RgbColor(255, 255, 255) +``` + +![Create TextAnnotation](images/pdf-processing-create-textannotation.png) + +### Creating a TextAnnotation with FixedContentEditor + +The FixedContentEditor offers the public **DrawTextAnnotation** method which creates a new TextAnnotation and draws it with a specified size and text and can create a PopupAnnotation to go with it. + +```csharp + RadFixedDocument fixedDocument = new RadFixedDocument(); + FixedContentEditor editor = new FixedContentEditor(fixedDocument.Pages.AddPage()); + editor.Position.Translate(100, 100); + Size annotationSize = new Size(50, 50); + Size popupSize = new Size(250, 100); + string text = "This is a TextAnnotation"; + bool addPopup = true; + editor.DrawTextAnnotation(annotationSize, popupSize, text, addPopup); + PopupAnnotation popupAnnotation = fixedDocument.Pages[0].Annotations[1] as PopupAnnotation; +``` + +![Create TextAnnotation with Popup](images/pdf-processing-create-textannotation-with-popup.png) + +### Creating a TextAnnotation with Appearance + +The **AnnotationContentSource** class, accessed by the **Content** property of the annotation object, represents the [FormSource]({%slug radpdfprocessing-model-formsource%}) instances used for displaying the widget content. The following example shows how to change the annotation's visual appearance when the mouse is not interacting with the widget (**NormalContentSource**) and when the mouse is over the widget (**MouseOverContentSource**): + +```csharp + private RadFixedDocument CreateTextAnnotation() + { + RadFixedDocument fixedDocument = new RadFixedDocument(); + RadFixedPage page = fixedDocument.Pages.AddPage(); + + TextAnnotation annotation = page.Annotations.AddText(new Rect(100, 100, 100, 50)); + annotation.Contents = "This is a TextAnnotation"; + FormSource normalForm = new FormSource(); + CreateContentFormWithText(normalForm, "Hover me"); + FormSource hoverForm = new FormSource(); + CreateContentFormWithText(hoverForm, "Done"); + + annotation.Content.NormalContentSource = normalForm; + annotation.Content.MouseOverContentSource = hoverForm; + return fixedDocument; + } + + private static void CreateContentFormWithText(FormSource normalForm, string text) + { + Size s = new Size(100, 40); + Random rand= new Random(); + normalForm.Size = s; + + FixedContentEditor formEditor = new FixedContentEditor(normalForm); + + using (formEditor.SaveProperties()) + { + formEditor.GraphicProperties.IsFilled = true; + formEditor.GraphicProperties.IsStroked = true; + formEditor.GraphicProperties.StrokeThickness = 1; + formEditor.GraphicProperties.StrokeColor = new RgbColor(255, 0, 0); + formEditor.GraphicProperties.FillColor = new RgbColor(255, 255, 0); + formEditor.GraphicProperties.StrokeDashArray = new double[] { 17, 4 }; + formEditor.DrawRectangle(new Rect(s)); + } + + formEditor.TextProperties.FontSize = 10; + formEditor.Position.Translate(10, 10); + formEditor.DrawText(text); + } +``` + +![Create TextAnnotation with Appearance](images/pdf-processing-create-textannotation-with-appearance.gif) + +It is possible to modify the content source displayed when the mouse button is pressed on the widget via the **MouseDownContentSource** property of the AnnotationContentSource. + +## See Also + +* [AcroForm]({%slug radpdfprocessing-model-interactive-forms-acroform %}) +* [FormField]({%slug radpdfprocessing-model-interactive-forms-form-fields%}) +* [Annotations Overview]({%slug radpdfprocessing-model-annotations-overview%}) +* [FormSource]({%slug radpdfprocessing-model-formsource%}) diff --git a/libraries/radpdfprocessing/model/annotations/widgets.md b/libraries/radpdfprocessing/model/annotations/widgets.md index 40d07a2b..253346f0 100644 --- a/libraries/radpdfprocessing/model/annotations/widgets.md +++ b/libraries/radpdfprocessing/model/annotations/widgets.md @@ -1,6 +1,7 @@ --- title: Widgets page_title: Widgets +description: Interactive forms use widget annotations to represent the appearance of fields and to manage user interactions. slug: radpdfprocessing-model-annotations-widgets tags: annotations,overview,pdfprocessing,widgets,widget published: True diff --git a/libraries/radpdfprocessing/model/formsource.md b/libraries/radpdfprocessing/model/formsource.md index 9d34119e..869a7dda 100644 --- a/libraries/radpdfprocessing/model/formsource.md +++ b/libraries/radpdfprocessing/model/formsource.md @@ -9,8 +9,6 @@ position: 7 # FormSource - - With __FormSource__ you can add content to a [Form]({%slug radpdfprocessing-model-form%}) object, which will be inserted in the PDF document. This article explains the following topics: * [Creating a FormSource](#creating-a-formsource) @@ -69,7 +67,6 @@ The FormSource class inherits from the IContentRootElement interface. This inher formEditor.DrawText("Sample rectangle in a form"); {{endregion}} - ## Inserting a FormSource into a Document After generating the FormSource object and filling it with content, you should insert it in the document. The API provides you with convenient approaches that might be useful to easily insert the form in different scenarios. @@ -97,6 +94,39 @@ After generating the FormSource object and filling it with content, you should i * When editing a Block, you can insert a FormSource object directly into it. For more information, check [this topic]({%slug radpdfprocessing-editing-block%}). +## Adding SVG into a Document + +As of **Q3 2024** RadPdfProcessing provides support for SVG (vector graphics image format). The static FormSource.**FromSvg** method allows the possibility to insert a vector image in the PDF document. The following overloads are publicly available: + +* **FormSource.FromSvg(string xml)** - Creates a FormSource object from an SVG file provided as a xml. + +* **FormSource.FromSvg(byte[] svgData)** - Creates a FormSource object from an SVG file provided as a byte[]. + +* **FormSource.FromSvg(Stream stream)** - Creates a FormSource object from an SVG file provided as a stream. + +The following example shows how to insert an SVG image into a FormSource object using FixedContentEditor: + +```csharp +string svgFilePath = "image.svg"; +RadFixedDocument fixedDocument = new RadFixedDocument(); +FixedContentEditor documentPageEditor = new FixedContentEditor(fixedDocument.Pages.AddPage()); +int offset = 10; +documentPageEditor.Position.Translate(offset, offset); + +FormSource svgHostForm = FormSource.FromSvg(File.ReadAllBytes(svgFilePath)); +documentPageEditor.DrawForm(svgHostForm); +//draw the SVG with its original size + +double aspectRatio = svgHostForm.Size.Width / svgHostForm.Size.Height; +//get the aspect ratio from the original SVG size +double desiredSVGWidth = 100; +double calculatedSVGHeight = desiredSVGWidth / aspectRatio; +documentPageEditor.Position.Translate(offset, svgHostForm.Size.Height + offset); +documentPageEditor.DrawForm(svgHostForm, new Size(desiredSVGWidth, calculatedSVGHeight)); +//draw the SVG with desired width preserving the aspect ratio +``` +![PdfProcessing Insert SVG](images/pdf-processing-insert-svg.png) + ## See Also * [Form]({%slug radpdfprocessing-model-form%}) diff --git a/libraries/radpdfprocessing/model/image.md b/libraries/radpdfprocessing/model/image.md index 39b41bf5..d22b2cab 100644 --- a/libraries/radpdfprocessing/model/image.md +++ b/libraries/radpdfprocessing/model/image.md @@ -9,7 +9,7 @@ position: 4 # Image -__Image__ is a content element, which contains an [ImageSource]({%slug radpdfprocessing-model-imagesource%}) and represents an image. It can be added in the __Content__ collection of a __IContainerElement__ such as [RadFixedPage]({%slug radpdfprocessing-model-radfixedpage%}). +**Image** is a content element, which contains an [ImageSource]({%slug radpdfprocessing-model-imagesource%}) and represents an image. It can be added in the **Content** collection of a **IContainerElement** such as [RadFixedPage]({%slug radpdfprocessing-model-radfixedpage%}). ## Working With an Image @@ -19,6 +19,8 @@ You can edit an __Image__ element using the properties the class exposes. The pr * __Width__: The width of the image. * __Height__: The height of the image. * __Position__: The [Position]({%slug radpdfprocessing-concepts-position%}) of the image inside the __IContainerElement__. + +>note As of **Q3 2024** RadPdfProcessing provides support for SVG (vector graphics image format): [Adding SVG into a Document](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/model/formsource#adding-svg-into-a-document). __Example 1__ shows how to initialize an Image object, assigns an ImageSource to it and add it to a previously defined container (page). diff --git a/libraries/radpdfprocessing/model/images/pdf-processing-insert-svg.png b/libraries/radpdfprocessing/model/images/pdf-processing-insert-svg.png new file mode 100644 index 00000000..baafbdbf Binary files /dev/null and b/libraries/radpdfprocessing/model/images/pdf-processing-insert-svg.png differ diff --git a/libraries/radpdfprocessing/model/imagesource.md b/libraries/radpdfprocessing/model/imagesource.md index eb4d74a6..968e31cb 100644 --- a/libraries/radpdfprocessing/model/imagesource.md +++ b/libraries/radpdfprocessing/model/imagesource.md @@ -9,10 +9,7 @@ position: 5 # ImageSource - - -__ImageSource__ represents a single, constant set of pixels at a certain size. It can be used by multiple [Image]({%slug radpdfprocessing-model-image%}) objects in order to be drawn in a PDF file. - +**ImageSource** represents a single, constant set of pixels at a certain size. It can be used by multiple [Image]({%slug radpdfprocessing-model-image%}) objects in order to be drawn in a PDF file. ## Creating an ImageSource @@ -102,4 +99,5 @@ __RadPdfProcessing__ exposes an extension method allowing you to convert every B ## See Also * [Image]({%slug radpdfprocessing-model-image%}) + * [Adding SVG into a Document](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/model/formsource#adding-svg-into-a-document) * [ImageSource API Reference](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource.html) diff --git a/libraries/radpdfprocessing/overview.md b/libraries/radpdfprocessing/overview.md index 04ae4af2..a896dffe 100644 --- a/libraries/radpdfprocessing/overview.md +++ b/libraries/radpdfprocessing/overview.md @@ -39,7 +39,7 @@ The document model of the library provides support for: |---------|-------------| | [**Pages**]({%slug radpdfprocessing-model-radfixedpage%}) | Adding, modifying or removing of pages in a document. The properties enable you to change the size of the page, its rotation, and more. | | **Automatic layout** | Although the PDF format is fixed, sometimes you will need to insert the content in a way that flows on the page. RadPdfProcessing enables to achieve this easily by using [blocks]({%slug radpdfprocessing-editing-block%}), [tables]({%slug radpdfprocessing-editing-table%}) and [lists]({%slug radpdfprocessing-editing-list%}). | -| [**Images**]({%slug radpdfprocessing-model-image%}) | Decoded on demand to achieve better performance. The API enables you to obtain the encoded image data. You can also control the image quality when saving the document. | +| [**Images**]({%slug radpdfprocessing-model-image%}) | Decoded on demand to achieve better performance. The API enables you to obtain the encoded image data. You can also control the image quality when saving the document. As of **Q3 2024** RadPdfProcessing provides support for SVG (vector graphics image format).| | [**Geometries**]({%slug radpdfprocessing-concepts-geometry%}) | Enable you to describe the geometry of a 2D shape. | | [**Form XObjects**]({%slug radpdfprocessing-model-form%}) | The Form XObjects enables you to describe composite objects (consisting of text, images, vector elements, etc.) within a PDF file and reuse this content among the document, for smaller document size and better rendering performance. | | [**Interactive Forms**]({%slug radpdfprocessing-model-interactive-forms-overview%}) | Create and modify PDF files containing textboxes, buttons, list boxes, and other interactive controls making available for the PDF file user to interactively fill some data in the PDF document and/or digitally sign the filled document. You can flatten the fields as well. | diff --git a/libraries/radspreadprocessing/features/shapes-and-images.md b/libraries/radspreadprocessing/features/shapes-and-images.md index 74e44ff0..b1bea0bf 100644 --- a/libraries/radspreadprocessing/features/shapes-and-images.md +++ b/libraries/radspreadprocessing/features/shapes-and-images.md @@ -44,48 +44,27 @@ The supported formats are: * **WMF** * **EMF** * **BIN** +* **SVG** (*introduced in 2024 Q3*) ## Properties of Shapes and Images -Shapes have the following properties: - - -* __CellIndex:__ The cell index where the top left corner of the shape is located when the shape is not rotated. - - -* __OffsetX:__ The offset between the left side of the shape and the left side of the cell index. - - -* __OffsetY:__ The offset between the top of the shape and the top of the cell index. - - -* __Width:__ The width of the shape. - - -* __Height:__ The height of the shape. - - -* __RotationAngle:__ The angle (in degrees) by which the shape is rotated about its center. - - -* __IsHorizontallyFlipped:__ Indicates whether the shape has been flipped across the y-axis. - - -* __IsVerticallyFlipped:__ Indicates whether the shape has been flipped across the x-axis. - - -* __Name:__ The name of the shape. - - -* __LockAspectRatio:__ Determines whether the aspect ratio between the width and the height of the image will be preserved. - - -* __Id:__ A unique number assigned to the image after it has been added to a worksheet. - - -* __Worksheet:__ The worksheet in which the shape is or will be inserted. - -* **Description**: Gets or sets the description of the shape. (*introduced in 2024 Q2*). +Shapes have the following properties: + +|Property|Description| +|----|----| +|__CellIndex__| The cell index where the top left corner of the shape is located when the shape is not rotated.| +|__OffsetX__| The offset between the left side of the shape and the left side of the cell index.| +|__OffsetY__| The offset between the top of the shape and the top of the cell index.| +|__Width__| The width of the shape.| +|__Height__| The height of the shape.| +|__RotationAngle__| The angle (in degrees) by which the shape is rotated about its center.| +|__IsHorizontallyFlipped__| Indicates whether the shape has been flipped across the y-axis.| +|__IsVerticallyFlipped__| Indicates whether the shape has been flipped across the x-axis.| +|__Name__| The name of the shape.| +|__LockAspectRatio__| Determines whether the aspect ratio between the width and the height of the image will be preserved.| +|__Id__| A unique number assigned to the image after it has been added to a worksheet.| +|__Worksheet__| The worksheet in which the shape is or will be inserted.| +|**Description**| Gets or sets the description of the shape. (*introduced in 2024 Q2*)| Images have one additional property: @@ -250,13 +229,14 @@ If we increase the rotation angle of the image, it will be visualized differentl It appears that the top left cell index is B5, however, the CellIndex property of the image will remain unchanged, B8, as will the offset. -This set up is convenient as it allows more intuitive rotation of the shapes. However, when the rotation angle increases substantially, the underlying CellIndex of the shape might become too distant to be useful. In order to avoid this, once the rotation angle becomes 45° and more, the CellIndex should switch to where the top left corner would be at 90° rotation. - +This set up is convenient as it allows more intuitive rotation of the shapes. However, when the rotation angle increases substantially, the underlying CellIndex of the shape might become too distant to be useful. In order to avoid this, once the rotation angle becomes 45° and more, the CellIndex should switch to where the top left corner would be at 90° rotation. This is illustrated in the following images: + ![Rad Spread Processing Features Shapes And Images 03](images/RadSpreadProcessing_Features_Shapes_And_Images_03.png) At this point, the CellIndex property of the shape is D1 and the offset should also be recalculated accordingly. + ![Rad Spread Processing Features Shapes And Images 04](images/RadSpreadProcessing_Features_Shapes_And_Images_04.png) As rotation increases, the CellIndex of the shape will switch between B8 and D1, depending on what is closer to the visual top left corner of the shape. The result will be the following: diff --git a/libraries/radspreadprocessing/overview.md b/libraries/radspreadprocessing/overview.md index 57afa5ec..e5a25814 100644 --- a/libraries/radspreadprocessing/overview.md +++ b/libraries/radspreadprocessing/overview.md @@ -38,7 +38,7 @@ The following table describes the most popular features of the RadSpreadProcessi | Feature | Description | |---------|-------------| -| [**Shapes and Images**]({%slug radspreadprocessing-features-shapes-and-images%}) | API for insertion, positioning and deletion of images in worksheets. | +| [**Shapes and Images**]({%slug radspreadprocessing-features-shapes-and-images%}) | API for insertion, positioning and deletion of images in worksheets. As of **Q3 2024** RadSpreadProcessing provides support for SVG (vector graphics image format). | | [**Charts**]({%slug radspreadprocessing-features-charts%}) | Add, remove and manipulate chart objects in your spreadsheet documents. | | [**Conditional Formatting**]({%slug radspreadprocessing-features-conditional-formatting%}) |Make it easy to analyze data, find critical issues, patterns and trends by representing the data inside in a user-friendly manner. | | [**Hyperlinks**]({%slug radspreadprocessing-features-hyperlink%}) | The API enables you to add, remove, edit and search for hyperlinks in the worksheets of the document. | diff --git a/libraries/radwordsprocessing/model/imageinline.md b/libraries/radwordsprocessing/model/imageinline.md index 3814cf34..d441cf3b 100644 --- a/libraries/radwordsprocessing/model/imageinline.md +++ b/libraries/radwordsprocessing/model/imageinline.md @@ -28,6 +28,7 @@ With **WordsProcessing**, you can work with images from the following file forma - WMF - EMF - BIN + - SVG (*introduced in 2024 Q3*) ## Inserting an ImageInline