Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Including .aspx in .asp pages

Hello all....

I hope there is some help out there. I know the title is a little weird ( since .net apps seem to be the way to go, but hear this out first )

I have a very simple .asp page that is a window into a database to find files based on specific search criteria from the user. After selecting files from the list of returned data, the user will hit a submit button that will take the selected files and merge them into one giant pdf document. Using vbscript for some reason does not allow the server request to take place, however the same application in .net architecture works.

I have already tried the FileSystemObject and using the "" tag and am not getting the results I need to see using just straight vbscript.

The reason for the change is that the .net apps are too bulky and we are trimming down quite a bit. I have already reworked two big .net apps into very simple vbscript ( asp ) pages.

Is there any way to include a .net (aspx) application within a vbscipt page? Any help here would be GREATLY appreciated.

Thanks in advance,
Eric

Comments

  • FinnsterFinnster Member Posts: 2
    [b][red]This message was edited by Finnster at 2006-6-21 4:27:7[/red][/b][hr]
    So I got to solve this riddle with a little help from a coworker...

    If Request.Form("mergeDocs") > "" Then
    fileList = Request.Form("fileList")
    Response.Redirect("../filepath/Merger.aspx?files=" & fileList)
    End If

    That code is in the main asp page and links over to an aspx page with code only that does the following:

    'WebPDFMerger takes in a list of files in a querystring format. These files
    ' represent PDF files in the VirtualDocs directory. WebPDFMerger will find
    ' these files, and merge them together into one PDF file
    'This code is adapted from old PDF merging code from the old DocSearchTool
    ' application, meant primarily for merging pages or sections of track charts
    ' together into a single file

    'constant declarations
    Const tempPath As String = "filepath"

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    'when this page is loaded, obtain the list of files from the querystring,
    ' and dump the filenames from the querystring into an array
    Dim fileString As String = Request.QueryString("files").Replace(" ", "")
    Dim fileArray As String() = fileString.Split(",")

    'using this newly created array full of filenames, find the files and copy
    ' them to a temporary directory local to the program folder
    Dim counter As Integer = 0
    Dim splitFilename As String()
    Dim fileName As String
    Dim destPath As String
    Do While counter < fileArray.Length
    'extract the filename
    splitFilename = fileArray(counter).Split("")
    fileName = splitFilename(splitFilename.Length - 1)

    'copy the file
    destPath = tempPath & fileName
    FileCopy(fileArray(counter), tempPath & fileName)

    counter = counter + 1
    Loop

    'finally, call CreateDoc to merge the documents together
    Call CreateDoc(fileArray)

    'show the link to the new file on the page
    Response.Write("
    Document merge has completed! Click the link below to view the file")
    Response.Write("View New Document")
    Response.Write("Click here to start a new search
    ")

    End Sub

    Public Function CreateDoc(ByVal fileArray As String()) As Boolean
    Dim newdir As String = "finished"
    Dim IGCtrl As New IGCoreCtl
    Dim IGFormatsCtl1 As New IGFormatsCtl
    Dim IGDisplayCtl1 As New IGDisplayCtl
    Dim IGProcessingCtl1 As New IGProcessingCtl
    Dim IGPDFCtl1 As New IGPDFCtl

    Dim igPage As IGPage
    Dim igDocument As IGDocument
    Dim ioLoc As IGIOFile
    Dim igLoadOpts As IGLoadOptions
    Dim nPages As Integer
    Dim i, a As Integer
    Dim errString As String
    Dim fileName As String
    Dim urlstring, urlinstr, urllength, fname As String
    Dim newfile As String
    Dim sCount As Integer = Session("sCount") + 1

    'if the finished directory doesn't exist, create it
    'Please NOTE That all directories have been removed for security.....
    If Directory.Exists("filepath") = False Then
    Directory.CreateDirectory("filepath")
    End If

    newfile = tempPath & newdir & " emp.pdf"
    File.Delete(newfile)

    Try
    '####################################################
    'Our licensing info went here ... so no peeking !!
    '####################################################
    IGCtrl.AssociateComponent(IGFormatsCtl1.ComponentInterface)
    IGCtrl.AssociateComponent(IGDisplayCtl1.ComponentInterface)
    IGCtrl.AssociateComponent(IGProcessingCtl1.ComponentInterface)
    Dim currentParameter As IGGlobalParameter

    currentParameter = IGCtrl.Settings.GetParamCopy("PDF.ENABLE_POSTSCRIPT")
    currentParameter.Value.Boolean = False

    IGCtrl.Settings.UpdateParamFrom(currentParameter)

    IGCtrl.AssociateComponent(IGPDFCtl1.ComponentInterface)
    IGCtrl.Result.NotificationFlags = enumIGErrorHandlingFlags.IG_ERR_NO_ACTION

    igPage = IGCtrl.CreatePage()
    igDocument = IGCtrl.CreateDocument(0)

    ioLoc = IGFormatsCtl1.CreateObject(enumIGFormatsObjType.IG_FORMATS_OBJ_IOFILE)
    igLoadOpts = IGFormatsCtl1.CreateObject(enumIGFormatsObjType.IG_FORMATS_OBJ_LOADOPTIONS)

    Dim counter = 0
    Dim lastFileMerged As String = ""
    Do While counter < fileArray.Length
    fileName = fileArray(counter)
    If fileName <> lastFileMerged Then
    ioLoc.FileName = fileName
    igLoadOpts.Format = enumIGFormats.IG_FORMAT_PDF
    nPages = IGFormatsCtl1.GetPageCount(ioLoc, enumIGFormats.IG_FORMAT_UNKNOWN)
    nPages = nPages - 1

    For i = 0 To nPages
    IGFormatsCtl1.LoadPage(igPage, ioLoc, i, 0, igLoadOpts)
    IGFormatsCtl1.SavePageToFile(igPage, newfile, 0, enumIGPageSaveModes.IG_PAGESAVEMODE_APPEND, enumIGSaveFormats.IG_SAVE_PDF_UNCOMP)
    Next
    lastFileMerged = fileName
    End If
    counter = counter + 1
    Loop

    igPage.Clear()
    igDocument.Clear()

    IGPDFCtl1 = Nothing
    IGCtrl = Nothing
    IGFormatsCtl1 = Nothing
    IGDisplayCtl1 = Nothing
    IGProcessingCtl1 = Nothing
    igPage = Nothing
    igDocument = Nothing
    ioLoc = Nothing
    igLoadOpts = Nothing
    nPages = Nothing

    Catch ex As Exception
    errString = "ImageGear document merge function failed. " & Chr(10) & "Error Message: " & ex.Message & Chr(10) & "Error Source: " & ex.Source
    Session("errmsg") = Session("errmsg") & errString & Chr(10)

    IGPDFCtl1 = Nothing
    IGCtrl = Nothing
    IGFormatsCtl1 = Nothing
    IGDisplayCtl1 = Nothing
    IGProcessingCtl1 = Nothing
    igPage = Nothing
    igDocument = Nothing
    ioLoc = Nothing
    igLoadOpts = Nothing
    nPages = Nothing
    'WriteError(errString, ex)

    End Try

    End Function




    There was also a write error function, but I didn't want to bore you with the details of that... so I hope the above helps out who ever might need it!!




Sign In or Register to comment.