We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Creating Annotations within pdf files using Aspose


Hi,

Can you please send me documentation for creating annotations i.e Redaction, Highlight, Comment etc.


Thanks

Hello Venkateswari,


Thanks for using our products.

Please visit the following link for required information on Working with Annotations.

HI,

I have worked with createtext function. That is nothing but giving a comment . But I want to hide particular rectangular area with color(redaction).I didnt find that partiar function for that. Can you please send me that.


Thanks in advance

Hello Venkateswari,


Please try using CreateMarkup or CreatePolygon methods present in PdfContentEditor class of Aspose.Pdf.Facades namespace. It allows you to specify rectangular area for the annotation object. In case you still face any issue or you have any further query, please feel free to contact. We are sorry for your inconvenience.

Hi,

Can we able to see the created annotations for pdf files other than pdfviewer?

If not we are not creating permanently. You are creating a overlay . Can you please tell me How aspose doing internally for creation of annotations within pdf files? I need to show my pdf file with radbinary image viewer and we need to download as it is(including annotations).


Thanks in advance

Hello Venkateswari,


Thanks for sharing the details.

Annotations are added as PDF component inside the PDF document rather than just overlaying them during display. Once you have added them, they will become the part of PDF file and will be displayed when viewing PDF document in any supported tool.

As per your requirement of displaying the PDF document in RadBinary Image viewer control, I think first you need to convert the pages of PDF file into Image format and then you can display them inside image viewer control. You may consider visiting the following link for information on Convert all PDF pages to JPEG Images

In case I have not properly understood your requirement or you have any further query, please feel free to contact. We are sorry for your inconvenience.

Hi,



I have created annotations like markup and comment on pdf file. And
now I am trying to open that file using Radbinary image. For this I am converting pdf file to jpeg image and showing with Radbinary image viewer. Now I am not getting previously created annotations. So that I am asking, are you creating an overlay or permanantly.

Converted from pdf to jpeg using below code:

PdfConverter convert = new PdfConverter();
convert.BindPdf(path);
convert.DoConvert();

string ConImgDestPath = @“D:\imagefile.jpg”;
convert.GetNextImage(ConImgDestPath, System.Drawing.Imaging.ImageFormat.Jpeg);


Thanks inadvance

Hello Venkateswari,


Thanks for sharing the details and sorry for replying you late.

If the source PDF file contains annotations, then during PDF conversion to images, the annotations appear on the resultant Image. As you are facing some issues during conversion process, can you please share some sample PDF documents, so that we can test the scenario at our end. We are really sorry for your inconvenience.

Hi,

Here I am attaching pdf files contains annotations. Please let me know what’s the issue.


Thanks in advance

Hello Venkateswari,


Thanks for sharing the resource files.

I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as
PDFNEWNET-33526. We
will investigate this issue in details and will keep you updated on the status
of a correction.

We
apologize for your inconvenience.

Could you let me know the status of this issue, as I’m seeing the same problem (rectangle annotations not being present on image renditions of a PDF page)?

If it’s not likely to be resolved soon, I guess a potential workaround would be to convert the annotations to actual drawing objects on the page prior to performing the rendering. If you can provide any sample code for drawing rectangles directly onto the canvas (i.e. not via an annotation) that would be much appreciated.

George

Hi George,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

GeorgeH:
Could you let me know the status of this issue, as I'm seeing the same problem (rectangle annotations not being present on image renditions of a PDF page)?

I have asked the development team to share an ETA regarding the resolution of this issue and as soon as I get a feedback from them, I will update you via this forum thread.

GeorgeH:

If it's not likely to be resolved soon, I guess a potential workaround would be to convert the annotations to actual drawing objects on the page prior to performing the rendering. If you can provide any sample code for drawing rectangles directly onto the canvas (i.e. not via an annotation) that would be much appreciated.

I am not sure about your requirement, please provide some more details, so we can reply you accordingly if any workaround is possible.

Sorry for the inconvenience,

nausherwan.aslam:

I am not sure about your requirement, please provide some more details, so we can reply you accordingly if any workaround is possible.



The workaround would be to look at any existing annotations (for now, I only care about lines and rectangles), and to replicate the annotation by drawing it directly onto the PDF page, so that it then appears in the converted image, e.g.

foreach (rectangle annotation on page)
{
get coordinates of rectangle
draw rectangle on page at those coordinates
}

by 'draw rectangle' here I mean draw a rectangle directly onto the canvas with PDF operators (lineto etc.) rather than as an annotation. I assume this is possible through Aspose, but at a quick look I didn't see any samples for this.

Thanks for your help.

George

Hi George,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the detailed explanation.

I am afraid, your requested feature to replace the annotation (by getting the location) with a rectangle drawing in an existing PDF is not supported at the moment. However, I have created a new feature request in our issue tracking system as PDFNEWNET-34415 for the development team to check if it can be supported.

Sorry for the inconvenience,

Hi Venkateswari,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We have received the following reply from the development team regarding your reported issue.

Annotations in your documents don't have AP entries, i.e. appearance dictionaries which specify how the annotations will be presented visually on the page. Therefore output jpegs don't contain annotations. However if you resave your PDF and perform the conversion again, it shows the annotations fine.

Please share the details how you are creating the annotation, so we can check further about this issue.

Sorry for the inconvenience,

Thanks for your reply. I’ve tried what you suggest, but it didn’t help, so I may have not understood correctly.


We were originally doing these steps:

1) Load PDF
2) Add square annotation
3) Convert page to TIFF

and we don’t see the annotation on the output TIFF.

Based on your suggestion, I tried the following:

1) Load PDF
2) Add square annotation
3) Save PDF to file
4) Reload PDF from file
5) Covert page to TIFF

but this didn’t seem to help (still no annotation visible). Have I understood the workaround correctly? Is there anything else I can try?

Best regards,

George

Hi George,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

<o:p> </o:p>

Thank
you for the feedback.<o:p></o:p>

<o:p> </o:p>

Well,
actually our development team would like to know the details about the template
PDF, the code to generate the annotations because as per their findings the
resultant file share over does not have appearance dictionaries which are
causing the problem in rendering the annotations to the resultant image file.
So, please share your template PDF file and sample code which you are using to
generate the annotation so that development team can further analyze this
issue. <o:p></o:p>

<o:p> </o:p>

The
process I shared in my previous post (for testing the PDF to Image process with
annotations) was to open the resultant PDF file in Adobe and save it. Then use
Aspose.Pdf for .NET to convert that file to image and you will be able to see
the annotation in the generated image. To understand the actual cause of the
issue, please share the above required items with us for further
investigations.<o:p></o:p>

<o:p> </o:p>

Sorry
for the inconvenience,<o:p></o:p>

Here’s some code to create the problem:

Document pdf = new Document();
pdf.Pages.Add();
SquareAnnotation sa = new SquareAnnotation(pdf.Pages[1], new Rectangle(0, 0, 400, 400)) { InteriorColor = Color.Parse("#000000") };
pdf.Pages[1].Annotations.Add(sa);
//pdf.Pages[1].Flatten();
TiffDevice tiffDevice = new TiffDevice();
tiffDevice.Process(pdf, @“out.tif”);

pdf.Save(@“out.pdf”);

The annotation is visible in the saved PDF, but not in the TIF. Uncommenting the flatten call also makes the annotation disappear in the PDF. I don’t use Acrobat, but have created annotations in other PDF tools with the same effect.




Yes, I have confirmed that opening and saving in Acrobat solves the problem, but obviously not a viable runtime solution :slight_smile:

Hi George,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the sample code.

I have shared the sample code with the development team for further investigation as I am able to see the issue using your code. Once we have any feedback from the development team, we will update you via this forum thread.

Sorry for the inconvenience,