Hi,
I am trying to print popup annotations.
There appear to be two annotations that make up the popup annotation.
A PdfTextAnnotation and a PdfPopupAnnotation.
When I print the pdf file, only the text annotation is printed.
I would like to be able to print the PdfPopupAnnotation when it is open on the pdf file.
We are using the Winforms version of the .Net Plug-in.
Thanks
Harlan
Printing pop-up annotations
Moderator: Alex
Re: Printing pop-up annotations
Hi Harlan,
PDF popup annotation does not have appearance but it has information about rectangle on PDF page, where popup annotation must be drawn. Appearance of PDF popup annotation depends from PDF reader application that displays PDF document. Our PDF Editor Demo uses WinForms user controls for displaying popup annotations.
Do you want to print PDF document with WinForms user controls?
Best regards, Alexander
PDF popup annotation does not have appearance but it has information about rectangle on PDF page, where popup annotation must be drawn. Appearance of PDF popup annotation depends from PDF reader application that displays PDF document. Our PDF Editor Demo uses WinForms user controls for displaying popup annotations.
Do you want to print PDF document with WinForms user controls?
Best regards, Alexander
-
- Posts: 85
- Joined: Fri Jan 24, 2020 3:37 am
Re: Printing pop-up annotations
Hi Alexander,
Printing the PDF document with WinForms user controls might work.
Do you have an example of this?
Thanks
Harlan
Printing the PDF document with WinForms user controls might work.
Do you have an example of this?
Thanks
Harlan
Re: Printing pop-up annotations
Hi Harlan,
We created example for your task but example needs functionality, which is not present in current version. Necessary functionality will be available in next minor version, which will be released next week. After version release we will provide example for your task.
Best regards, Alexander
We created example for your task but example needs functionality, which is not present in current version. Necessary functionality will be available in next minor version, which will be released next week. After version release we will provide example for your task.
Best regards, Alexander
Re: Printing pop-up annotations
Hi Harlan,
In version 9.0.0.15 we have added the CommentVisualTool.GetCommentControlsByImage method and this allows to create simple example that shows how to print PDF document with WinForms comment controls. Please use the CommentedPdfPrintDocument class (code can be found below) for printing PDF document with WinForms comment controls and let me know if you will have any question or problem.
Source codes of CommentedPdfPrintDocument class:
Best regards, Alexander
In version 9.0.0.15 we have added the CommentVisualTool.GetCommentControlsByImage method and this allows to create simple example that shows how to print PDF document with WinForms comment controls. Please use the CommentedPdfPrintDocument class (code can be found below) for printing PDF document with WinForms comment controls and let me know if you will have any question or problem.
Source codes of CommentedPdfPrintDocument class:
Code: Select all
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Vintasoft.Imaging;
using Vintasoft.Imaging.Annotation.UI.Comments;
using Vintasoft.Imaging.Annotation.UI.VisualTools;
using Vintasoft.Imaging.Pdf.Print;
using Vintasoft.Imaging.Utils;
namespace DemosCommonCode.Pdf
{
/// <summary>
/// Sends images with comment controls to a printer.
/// </summary>
public class CommentedPdfPrintDocument : PdfPrintDocument
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="CommentedPdfPrintDocument"/> class.
/// </summary>
public CommentedPdfPrintDocument()
: this(null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="CommentedPdfPrintDocument"/> class.
/// </summary>
/// <param name="commentTool">The comment visual tool.</param>
public CommentedPdfPrintDocument(CommentVisualTool commentTool)
{
_commentTool = commentTool;
}
#endregion
#region Properties
CommentVisualTool _commentTool;
/// <summary>
/// Gets or sets the comment visual tool.
/// </summary>
public CommentVisualTool CommentTool
{
get
{
return _commentTool;
}
set
{
_commentTool = value;
}
}
#endregion
#region Methods
/// <summary>
/// Draws the specified rectangular area of <see cref="T:Vintasoft.Imaging.VintasoftImage" /> on
/// the specified rectangular area of page's <see cref="T:System.Drawing.Graphics" />.
/// </summary>
/// <param name="image">Image to draw.</param>
/// <param name="graphics">Page's graphics, where image should be drawn.</param>
/// <param name="sourceRect">The rectangular area, in device-independent pixels (1/96th inch),
/// of image to draw.</param>
/// <param name="destRect">The rectangular area, in pixels, of page's graphics
/// where image should be drawn.</param>
/// <param name="printerResolutionX">The resolution of printer along X-axis.</param>
/// <param name="printerResolutionY">The resolution of printer along Y-axis.</param>
protected override void DrawImage(
VintasoftImage image,
Graphics graphics,
RectangleF sourceRect,
RectangleF destRect,
float printerResolutionX,
float printerResolutionY)
{
base.DrawImage(image, graphics, sourceRect, destRect, printerResolutionX, printerResolutionY);
// if comment visual tool is specified
if (_commentTool != null)
{
// get comment controls of current image
IEnumerable<ICommentControl> commentsControl = _commentTool.GetCommentControlsByImage(image);
foreach (ICommentControl commentControl in commentsControl)
{
// create transform from device independent pixels (DIPs) to pixels for specified resolution
PointFTransform transformFromDipToPixels = PointFAffineTransform.FromMatrix(
UnitOfMeasureConverter.GetTransformFromDip(UnitOfMeasure.Pixels,
new Resolution(printerResolutionX, printerResolutionY)));
// get comment bounding box in pixels
RectangleF commentBBoxInPixels = PointFAffineTransform.TransformBoundingBox(
transformFromDipToPixels, commentControl.Comment.BoundingBox);
// draw comment control
DrawCommentControlOnGraphics(
commentControl,
graphics,
Rectangle.Round(commentBBoxInPixels));
}
}
}
/// <summary>
/// Draws the comment control on graphics.
/// </summary>
/// <param name="commentControl">The comment control for draw.</param>
/// <param name="graphics">The graphics.</param>
/// <param name="destRect">The destination rect on graphics in pixels.</param>
public static void DrawCommentControlOnGraphics(
ICommentControl commentControl,
Graphics graphics,
RectangleF destRect)
{
Control control = commentControl as Control;
if (control == null)
return;
Rectangle rectOfControl = new Rectangle(0, 0, control.Width, control.Height);
// create bitmap
using (Bitmap bmp = new Bitmap(rectOfControl.Width, rectOfControl.Height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb))
{
// draw contol on bitmap
control.DrawToBitmap(bmp, rectOfControl);
// draw control bitmap on graphics
graphics.DrawImage(bmp, destRect);
}
}
#endregion
}
}