CreateJavaScriptLink function is behaving different on different PDF Forms

Hi,

We are using Aspose.Pdf.Kit for reading and manipulating the fields present on the form. I am trying to add a rectangle on top of each controls present on the PDF form so that whenever user clicks on any control a popup window appears. I am achieving this functionality by using the below code.

editor.CreateJavaScriptLink("app.alert('welcome to aspose!"');", rect, 1, color);

The behavior of the rectangle is not same for all the PDF forms. I tried with two PDF forms in one all alignment are correct and in another all the rectangles are misaligned. I have attached the PDFs that I have used. The x and y coordinates are not correct.

Could you please tell me what is the difference between these two PDFs? And also what is the cause for misalignment?

Thanks a lot.

Hi Sangamesh,

As I can see the alignment is not correct in f1042t–2009.pdf file. However, if you could share both the input PDF files (before adding JavaScript) along with the complete code snippet which you’re using at your end, we’ll be able to reproduce this issue at our end and then investigate it using your particular scenario. You’ll be updated with the results accordingly.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

Hi,
Thanks for the reply. Here is the source code - I have also attached the input and output files.

static void Main(string[] args)
{
//ActivePdf
Toolkit kit = new Toolkit();
Aspose.Pdf.Kit.License license = new Aspose.Pdf.Kit.License();
Directory.SetCurrentDirectory(Environment.CurrentDirectory + “\PDFMapper”);
//license.SetLicense(@“c:\aspose\aspose.total.lic”);
foreach(string file in Directory.GetFiles(Directory.GetCurrentDirectory()))
{
CreateForm(file);
}
}
public static void CreateForm(string fileName)
{
//First a input pdf file should be assigned
Aspose.Pdf.Kit.Form form = new Aspose.Pdf.Kit.Form(fileName);
//get all field names
String[] allfields = form.FieldNames;
//create PdfContentEditor object to create JavaScript Link
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(fileName);
System.Drawing.Color color = Color.FromArgb(255, 0, 255);
for (int i = 0; i < allfields.Length; i++)
{
// Get the appearance attributes of each field, consequtively
FormFieldFacade facade = form.GetFieldFacade(allfields[i]);
editor.CreateJavaScriptLink(“app.alert(‘welcome to aspose!’);”, facade.Box, 1, color);
}
editor.Save(“output.pdf”);
form.Save();
}

Hi Sangamesh,

Thank you very much for sharing the sample files and the code snippet. We’ll investigate this issue at our end and update you with the results shortly.

We’re sorry for the inconvenience.
Regards,

Hi Sangamesh,

I have reproduced this problem at my end and logged it as PDFKITNET-28591 in our issue tracking system. Our team will investigate this issue and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,

Hi,

Any update on the issue?

Thanks,
Sanga

Hi Sangamesh,

I’m sorry to inform you that this issue is not yet resolved. However, I have asked our team to share the ETA of this issue. You’ll be updated via this forum thread as soon as the response is received.

We’re sorry for the inconvenience.
Regards,

Hi,

If it is taking time to figure out the issue, is there any work around to achieve this? Basically I would like to get the position (coordinates) of each controls present on the PDF. Any inputs will be of great help.

Hi Sangamesh,

Our team is still investigating this issue and I’m sorry to share with you that it is not feasible for us to share the ETA of this issue at the moment. Also, this issue is caused due to the particular structure of the PDF file, it is not feasible for us to provide a workaround at the moment.

We’re sorry for the inconvenience.
Regards,

The issues you have found earlier (filed as 28591) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.