We cannot get merger to write to the given path. We are converting files to pdf and then merging them together. Converter works fine but merger seems to hang up. See code below :
Protected Sub BUTTONPRINTOFI_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BUTTONPRINTOFI.Click
Dim mergerfile As ceTe.DynamicPDF.Merger.MergeDocument
'array of filestrings
Dim filestring() As String
Dim imarshelper As New IMARSFactory
Dim attachmentds As New System.Data.DataSet
Dim row As System.Data.DataRow
Dim filename As String
Dim i As Integer
Dim tempfile As String
Dim mergepdf As String
Dim ispdf As String
' ceTe.DynamicPDF.Conversion.Converter.AddLicense
' convert regular pdf ffile
mergepdf = "d:\inetpub\userwebapps\EmergencyOps\tmp\temp" & Me.IMARSID.Text & ".pdf"
' mergepdf = "c:\websites\imars\TMP\temp" & Me.IMARSID.Text & ".pdf"
' ceTe.DynamicPDF.Conversion.Converter.Convert("HTTP://localhost:4073/imars/imarspdf.aspx?imars_id=" & Me.IMARSID.Text & "&wf_id=" & Me.wf_id.Value, mergepdf)
ceTe.DynamicPDF.Conversion.Converter.Convert("HTTP://gpweb.sandia.gov/emergencyops/imarspdf.aspx?imars_id=" & Me.IMARSID.Text & "&wf_id=" & Me.wf_id.Value, mergepdf)
' convert correspondence history
tempfile = "d:\inetpub\userwebapps\EmergencyOps-dev\tmp\temphistory" & Me.IMARSID.Text & ".pdf"
' tempfile = "c:\websites\imars\tmp\temphistory" & Me.IMARSID.Text & ".pdf"
ceTe.DynamicPDF.Conversion.Converter.Convert("HTTP://gpweb.sandia.gov/emergencyops/CORRESPONDENCEHISTORY.aspx?imarsid=" & Me.IMARSID.Text & "&wfid=" & Me.wf_id.Value, tempfile)
' ceTe.DynamicPDF.Conversion.Converter.Convert("HTTP://localhost:4073/imars/CORRESPONDENCEHISTORY.aspx?imarsid=" & Me.IMARSID.Text & "&wfid=" & Me.wf_id.Value, tempfile)
' merge two files
mergerfile = MergeDocument.Merge(mergepdf, tempfile)
' get attachments
attachmentds = imarshelper.GetIMARSAttachments("IMARS", Me.IMARSID.Text)
i = 1
If attachmentds.Tables(0).Rows.Count > 0 Then
For Each row In attachmentds.Tables(0).Rows
ReDim Preserve filestring(i)
' get first filename
filename = row("filename").ToString()
filestring(i) = "d:\inetpub\userwebapps\EmergencyOps\records\" & filename
' grab it
' filestring(i) = "c:\websites\IMARS\records\" & filename
' If System.IO.File.Exists(filestring(i)) Then
' check to see if it exists in this folder
' if its a pdf strip off the pdf part
If InStr(filename, ".") > 0 Then
ispdf = Right(filename, InStr(filename, ".") + 1)
filename = Left(filename, InStr(filename, ".") - 1)
End If
tempfile = "d:\inetpub\userwebapps\EmergencyOps\tmp\" & filename & ".pdf"
' tempfile = "c:\websites\IMARS\tmp\" & filename & ".pdf"
Try
If ispdf <> "pdf" Then
ceTe.DynamicPDF.Conversion.Converter.Convert(filestring(i), tempfile)
End If
mergerfile.Append(tempfile)
Catch ex As System.Exception
Response.Write("<script>")
Response.Write("alert('Failure to find attachment file: )" & filestring(i) & "Please contact your system programmers.';")
Response.Write("</script>")
Exit Sub
End Try
Next
End If
mergerfile.Draw("d:\inetput\userwebapps\EmergencyOps\tmp\screenmerged" & Me.IMARSID.Text & ".pdf")
Response.Redirect("http://gpweb.sandia.gov/emergencyops/tmp/mergerfile" & Me.IMARSID.Text & ".pdf")
Mergerfile.Draw
Re: Mergerfile.Draw
Support · Apr 6, 2010Hello,
Can you please make sure that you have permissions to write to the folder where you are trying to save the merged file?
mergerfile.Draw("d:\inetput\userwebapps\EmergencyOps\tmp\screenmerged" & Me.IMARSID.Text & ".pdf")
Can you try saving it to a temp folder and see if that wroks for you?
Thanks,
ceTe Software Support Team
Re: Mergerfile.Draw
Forum member · Apr 6, 2010We are saving it to a temp folder (we just called it tmp). We do have permission to write to it. Converter writes to the same location and it works, so I dont think that is not the problem.
Re: Mergerfile.Draw
Support · Apr 7, 2010Hello,
Are you getting any error? If you are getting error then please provide us the full error stack trace to look into it further. Can you please check which code hangs exactly? Are you having problem in the Draw method or while merging the documents? Can you please debug and see where the problem comes? Also please try drawing the document to any other folder and see if that works?
Thanks,
ceTe Software Support Team.
Re: Mergerfile.Draw
Forum member · Apr 7, 2010I believe it is hanging up on draw. It runs on my local machine, but not on the server. I can't debug from the server to provide you the error. We have read and write permission to the path provided to you, so I am not sure what is happening. Do you have any other suggestions on draw perhaps?
Re: Mergerfile.Draw
Support · Apr 7, 2010Hello,
If it is working in the local machine means the code has no problems. Can you check the folder where you are saving the PDF after conversion to see if the conversion worked fine? Delete the files in this folder and then run the code to see if the converter created the file or not. This is to make sure that the converter is working.
It looks like this is a web application, so have you given the read write access to the IUSR_MachineName or ASPNET user on that folder? Please try giving the permissions to this account it may work for you.
Thanks,
ceTe Software Support Team.
Re: Mergerfile.Draw
Forum member · Apr 7, 2010Okay, here's the deal.
We know the code works. Not a problem. All folders have proper permissions.
I merge two documents and then append to that documents.
merger.append(file)
when i run this code
merger.draw("d:\inetput\userwebapps\emergencyops-dev\screenmerged293.pdf")
d: being the hard code file path on the server....
we get this error on the server
Server Error in '/emergencyops-dev' Application.
________________________________________
Could not find a part of the path 'd:\inetput\userwebapps\EmergencyOps-dev\tmp\screenmerged293.pdf'.
so, what could be causing this?
Thanks,
Mary Ann
Re: Mergerfile.Draw
Support · Apr 7, 2010Hello Mary Ann,
This exact error we got when we used a wrong file path, so you might be using a wrong file path in this case. Please double check the path you are using if there is any typo.
Thanks,
ceTe Software Support Team.
Re: Mergerfile.Draw
Forum member · Apr 7, 2010the path is correct because my converter files are being written there without a problem. no problem with converter just with merger.
Re: Mergerfile.Draw
Forum member · Apr 7, 2010What permissions are we supposed to have on IUSR_MachineName and aspnet_machinename? read and write, full control etc? Should they both have permissions or just one or the other?
If the server is running 128bit encrytion, would that cause any problems.
We upgraded to IE8 as well.Would this cause problems.
Could you give me a complete server configuration? We are running out of time and really need this up and running soon.
Re: Mergerfile.Draw
Forum member · Apr 7, 2010In addition to last posting, I need to know about folder permissions.
Re: Mergerfile.Draw
Support · Apr 7, 2010Hello,
I see that you are saving the tempfile in "EmergencyOps-dev" folder after doing the conversion and saving the mergepdf file in "EmergencyOps" folder after doing the conversion.
You will need to give the IUSR_MachineName and ASPNET_MachineName accounts read and write permissions on the folder where you are attempting to draw the output PDF document.
Running 128-bit encryption or using IE8 should not be the cause of the problem. Can you try to save the output PDF using the Draw method to "C:\Temp\" directory and see if that works or not?
Thanks,
ceTe Software Support Team
Re: Mergerfile.Draw
Forum member · Apr 7, 2010that was just a typo on the -dev thing.
I can save the file running from my machine (merge) to my c drive without a problem.
Re: Mergerfile.Draw
Forum member · Apr 7, 2010Would setting permissions to full control for the iuser and aspnet accounts make a difference as opposed to read and write only?
Re: Mergerfile.Draw
Forum member · Apr 7, 2010Would setting permissions to full control for the iuser and aspnet accounts make a difference as opposed to read and write only?
Re: Mergerfile.Draw
Support · Apr 7, 2010Hello,
Giving full permissions would take care of giving the read and write permissions. Since you are able to write to the C drive, it likely appears to be a permissions issue with saving the output merged PDF file to that folder.
Thanks,
ceTe Software Support Team