Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Problem with Mender object

$
0
0

Hi,

   We are trying to read a field's co-ordinates from PDF file & replace those co-ordinates with an Image & then remove that field.

    I'm using following code:

_________________________________________________________________________

 Dim objLic As New Aspose.Pdf.Kit.License
 objLic.SetLicense("Aspose.Total.lic")
 Dim myLib As New PDFSplit
 Dim form As New Aspose.Pdf.Kit.Form(sFilename)
 Dim sFields() As String = form.FieldNames
 
 If Array.IndexOf(sFields, sFieldName) <> -1 Then
  Dim box As Rectangle = form.GetFieldFacade(sFieldName).Box
  
  Dim msOut As New MemoryStream()
  
  Dim Mender As New PdfFileMend(myLib.CreateMemoryStream(sFilename), msOut)
  Mender.AddImage(sImageFilename, 1, box.X, box.Y - box.Height, box.Right, box.Bottom)
  Mender.Close()
  
  Threading.Thread.Sleep(500)
  
  Dim fsFinalOut As New FileStream(sFilename, FileMode.Create, FileAccess.Write)
  Dim myformeditor As New Aspose.Pdf.Kit.FormEditor(msOut, fsFinalOut)
  myformeditor.RemoveField(sFieldName)
  myformeditor.Save()
  fsFinalOut.Close()
 End If
_________________________________________________________________________

Problem I'm facing is that whenever I supply the sFileName with local machine path, it works perfectly, but instead of that if I give any other machine's path to store the output file, it fails & gives no error!

 I have checked for access permissions on other machine's shared folder & they are ok. (Other part of my application which are creating file/folder related activities(creation/deletion) are working fine)... so it doesn't seems like an access permission issue.
  We have tried this code firstly with (filename,filename) version of PdfFileMend, but found that even after mender.close statement, file was not created completely. I was getting Object Reference not set error for

  Dim myformeditor As New Aspose.Pdf.Kit.FormEditor(1stfile,2ndfile)

this statement. Investigating further, came to know that, mender is not flushing the file & releasing it immidiately after mender.close statement & file was remaining locked untill it finishes flushing. Due to this, to avoid any file handling during this process, we switched to (stream,stream) version, but still getting the same error! which was more confusing.

This problem was ocurring frequently whenever we tried to use other machine's shared path & sometimes on the local machine's path too.


Viewing all articles
Browse latest Browse all 3131

Trending Articles