Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions PDF-to-image/PDFToImage_Annotation_Appearance/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="PDFToImage_Annotation_Appearance.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PDFToImage_Annotation_Appearance"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
14 changes: 14 additions & 0 deletions PDF-to-image/PDFToImage_Annotation_Appearance/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Configuration;
using System.Data;
using System.Windows;

namespace PDFToImage_Annotation_Appearance
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}

}
10 changes: 10 additions & 0 deletions PDF-to-image/PDFToImage_Annotation_Appearance/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
12 changes: 12 additions & 0 deletions PDF-to-image/PDFToImage_Annotation_Appearance/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Window x:Class="PDFToImage_Annotation_Appearance.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PDFToImage_Annotation_Appearance"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button Content="Button" HorizontalAlignment="Left" Margin="10" VerticalAlignment="Top" Click="Button_Click"/>
</Grid>
</Window>
63 changes: 63 additions & 0 deletions PDF-to-image/PDFToImage_Annotation_Appearance/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Interactive;
using Syncfusion.PdfToImageConverter;
using System.Drawing;
using System.IO;
using System.Windows;

namespace PDFToImage_Annotation_Appearance
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
//Creates a new pdf document
PdfDocument document = new PdfDocument();
//Creates a new page
PdfPage page = document.Pages.Add();

//Creates PDF free text annotation
PdfFreeTextAnnotation freeText = new PdfFreeTextAnnotation(new RectangleF(50, 100, 100, 50));
//Sets properties to the annotation
freeText.MarkupText = "Free Text with Callout";
freeText.TextMarkupColor = new PdfColor(System.Drawing.Color.Black);
freeText.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 7f);
freeText.Color = new PdfColor(System.Drawing.Color.Yellow);
freeText.BorderColor = new PdfColor(System.Drawing.Color.Red);
freeText.Border = new PdfAnnotationBorder(.5f);
freeText.LineEndingStyle = PdfLineEndingStyle.OpenArrow;
freeText.AnnotationFlags = PdfAnnotationFlags.Default;
freeText.Text = "Free Text";
freeText.Opacity = 0.5f;
PointF[] points = { new PointF(100, 450), new PointF(100, 200), new PointF(100, 150) };
freeText.CalloutLines = points;
freeText.SetAppearance(true);
//Adds the annotation to page
page.Annotations.Add(freeText);

//Save the document
document.Save("../../../Output.pdf");
//Closes the document
document.Close(true);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
PdfToImageConverter imageConverter = new PdfToImageConverter();
using (FileStream inputStream = new FileStream("../../../Output.pdf", FileMode.Open, FileAccess.ReadWrite))
{
imageConverter.Load(inputStream);
// Convert the first page (index 0)
using (Stream outputStream = imageConverter.Convert(0, false, false))
using (Bitmap Image = new Bitmap(outputStream))
{
Image.Save("sample.png"); // Produces an image that includes the FreeText annotation
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" />
<PackageReference Include="System.Drawing.Common" Version="10.0.1" />
</ItemGroup>
<Import Project="targets\MultiTargeting.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="PDFToImage_Annotation_Appearance.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net462;net8.0-windows;net9.0-windows;net10.0-windows</TargetFrameworks>
<UseWPF>true</UseWPF>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<EnableDefaultItems>True</EnableDefaultItems>
<EnableDefaultEmbeddedResourceItems>True</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>
</Project>