ASP
  Home arrow ASP arrow Adobe Reports in an ASP Web Page
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Adobe Reports in an ASP Web Page
By: Matt Burnett
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2003-02-04

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    In this article, Matt shows us how to use Adobe Active Reports in our ASP web pages using a custom made VB component.This article is a quick example on inserting Adobe report documents into a browser and using Adobe Reader to display them.

    I am using MS 2000 Server, IIS5.0 and ASP to implement this article's functions. Additionally, you will need Adobe Reader installed on your machine, VB6.0 and Active Reports. (Adobe Reader is a free download.)

    In the support file is a picture of the project in VB6.0.

    The process of presenting the document is 1) to build and compile a VB COM object using Active Reports to output the report, and 2) calling the COM object from the server code in an ASP page to present the report.

    An example of this can be found at
    http://www.datadynamics.com/default.aspx
    ...however, I accomplished this task a little differently, and I think it’s useful for other programmers to see it.

    Our VB object uses a single function to call the designers needed to create the report:

    ' VB6 code of Generalized function to generate the report.
    Public Function GenerateReport (ByVal ReportDate As Date, ByVal LOF As String, ByVal Funding As String, _
        ByVal SubFunding As String) As Variant
      Dim oPDF As ActiveReportsPDFExport.ARExportPDF
      
      ' create Active Report designer objects
      Set oRpt = New rptPerfStds
      oRpt.Printer.Orientation = ddOLandscape
      'Go build the report with the oRpt object!
      'After that
      oRpt.Pages.Insert intPageCount, YourReport.Pages(i)
      'export to pdf
      Set oPDF = New ActiveReportsPDFExport.ARExportPDF
      ' pdf and tmp will be in current folder:
      oPDF.FileName = modGenReporting.GenerateTempPDF(App.Path)
      oRpt.Export oPDF
      
      'create byte file for output report
      GenerateReport = modGenReporting.StreamFile(oPDF.FileName)
      
      'kill pdf file and temp file
      modGenReporting.DeleteTempPDF oPDF.FileName
    End Function


    A big step after creating the report is preparing the report for export which requires a temp file. This function:

    modGenReporting.GenerateTempPDF(App.Path)

    ...is a little complex, so lets show how the temp file is made:

    Public Function GenerateTempPDF(strPath As String, Optional strPrefix As String = "tmp") As String
      Dim strTempName As String
      
      strTempName = GenTempName(strPath, strPrefix)
      If UCase(Right(strTempName, 4)) = ".TMP" Then
        GenerateTempPDF = Left(strTempName, Len(strTempName) - 4) & ".pdf"
      Else
        Err.Raise vbObjectError + GEN_REPORTING_ERR_UNEXPECTED_EXT, "GenerateTempPDF", "Unexpected file name format"
      End If
    End Function

    Public Function GenTempName(strPath As String, Optional strPrefix As String = "tmp")
      Dim lngUnique As Long
      Dim strTempFileName As String
      lngUnique = 0
      strTempFileName = Space$(100)
      GetTempFileName strPath, strPrefix, lngUnique, strTempFileName
      If Trim(strTempFileName) = "" Then
        strTempFileName = ""
        Err.Raise vbObjectError + GEN_REPORTING_ERR_NO_TEMP_FILE, "modGenReporting.GenTempName", "Error creating temporary file."
      Else
        strTempFileName = Mid$(strTempFileName, 1, InStr(strTempFileName, Chr$(0)) - 1)
      End If
      GenTempName = strTempFileName
      Exit Function
    End Function

    Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long


    Ok, now to stream the file to the .ASP page for display with function:

    modGenReporting.StreamFile

    We use this:

    Public Function StreamFile(ByVal strFileName As String)
    On Error GoTo ErrHnd
      Dim lngFlen As Long
      Dim bytStream() As Byte
      Dim strBinFile As String
      Dim intFHan As Integer
      
      intFHan = FreeFile
      
      lngFlen = FileLen(strFileName)
      ReDim bytStream(lngFlen)
      
      Open strFileName For Binary Access Read As #intFHan
      
      Get #intFHan, , bytStream
      
      Close #intFHan
      
      StreamFile = bytStream
      
      Exit Function
    End Function


    Then, set the stream to the return value the function: GenerateReport = byte stream.

    Compile and register your COM object on the Web Server.

    Lastly, call the COM within your ASP page:
    (ASP VBS Server code)

    'get report info from query string
    strOfficeId = Request.QueryString("office")
    strFundingSource = Request.QueryString("FundSource")
    strFundingSubCat = Request.QueryString("FundSubCat")
    'instantiate the report with whatever class name you gave it
    set oRpt = Server.CreateObject("WIAPSServer.cWIAPerfStds")
    'set up the HTTP Content-Type, and write out the report in binary
    Response.ContentType="application/pdf"
    Response.BinaryWrite oRpt.GenerateReport(CDate(Now),strOfficeId,strFundingSource,strFundingSubCat)


    The browser will respond by opening Adobe Reader to display the output. If the Reader is not installed you will be prompted to download it. This method of displaying reports should work for either Netscape or IE.

    Questions can be directed to burnettm@hotmail.com, but I don't promise to answer them ( ;o) ). However, the reference to Data Dynamics is a good one and I would use that first.

    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More ASP Articles
    More By Matt Burnett

     

    IBM® developerWorks developerWorks - FREE Tools!


    Be the first to hear about i5/OS V6R1!

    Hold your calendar on January 30, 2008 for this free webcast on the new i5/OS. Rational's Enterprise Modernization products will be discussed at this webcast as they help to drive the application development environment for this new System i OS. <br />And learn how i5/OS will take you to the next step of efficient, resilient business processing. You will hear about the new i5/OS capabilities as it will be the most significant i5/OS release in years. If you cannot join the webcast on 1/30/08 you can still use this link to listen to the replay.<br />
    FREE! Go There Now!


    NEW! Download IBM Data Studio V1.1

    Visit IBM developerWorks to download the latest trial version of IBM Data Studio V1.1 at no cost. IBM Data Studio is a comprehensive data management solution that helps you effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life cycle utilizing a consistent and integrated user interface. Unlike other client-side data management solutions that focus on only one aspect of the application lifecycle or database administration, Data Studio complements the Rational Software Delivery platform, providing unparalleled flexibility for a heterogeneous data server environment across platforms.
    FREE! Go There Now!


    NEW! Evaluate Rational Business Developer V7.1

    Visit IBM developerWorks to download a free trial version of IBM Rational Business Developer V7.1. Rational Business Developer offers rapid and simplified development of business applications and services through Enterprise Generation Language (EGL) tools, generating Java or mainframe solutions while shielding developers from technical complexities.
    FREE! Go There Now!


    NEW! Hello World: Learn how to install and use the Rational Asset Manager Eclipse client

    In this tutorial, you can learn how to install and configure the IBM Rational Asset Manager Eclipse client, explore the different views in the Asset Management perspective, learn various search techniques, work with existing assets, and submit a new asset.
    FREE! Go There Now!


    NEW! Run your first CICS application on a PC using TXSeries for Windows

    Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1.
    FREE! Go There Now!


    NEW! The role of integrated requirements management in software delivery

    This paper is about the critical role that a discipline called integrated require­ments management can play in helping to ensure that your business goals and IT investments are continuously aligned—whether you are sourcing, integrat­ing, building or maintaining software. It also looks at ways that automated IBM Rational® products can work together to help you use requirements in the very best way.
    FREE! Go There Now!


    NEW! Trial download: IBM Informix Dynamic Server Express Edition V11.0

    Informix Dynamic Server (IDS) Express Edition offers outstanding online transaction processing (OLTP) database performance, while helping to simplify and automate many of the tasks associated with deploying databases for small business applications. IDS 11 further extends the ease of management and applications integration with the Admin API and Scheduler, high availability with Continuous Log Restore for backup server recovery in case of a primary server failure, and column level encryption to protect personal and company private data.
    FREE! Go There Now!


    NEW! Try IBM Rational Asset Manager V7.0 online!

    You can now evaluate IBM Rational Asset Manager V7.0 online without installing or configuring it on your own system! Rational Asset Manager helps create, modify, govern, find, and reuse any type of development assets, including SOA and systems development assets. Rational Asset Manager helps you reduce software development costs and improve quality by facilitating the reuse of all types of software development-related assets. Visit developerWorks to learn more about this product and register to explore its capabilities online.
    FREE! Go There Now!


    NEW! Webcast: Quickly provide customized, integrated user interfaces with Lotus Notes 8

    IBM Lotus Notes 8 provides a wide range of developers the ability to provide customized, integrated user interfaces via composite applications and via custom sidebar and toolbar plug-ins. This webcast provides you with tips and techniques to use with out-of-the-box capabilities of Lotus Notes 8, and survey how you can share useful components within your own company and within a larger community.
    FREE! Go There Now!


    NEW! Webcast: WebSphere Process Server

    WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP ARTICLES

    - Central Scoreboard with Flash and ASP
    - Calorie Counter Using WAP and ASP
    - Creating PGP-Encrypted E-Mails Using ASP
    - Be My Guest in ASP
    - Session Replacement in ASP
    - Securing ASP Data Access Credentials Using t...
    - The Not So Ordinary Address Book
    - Adding and Displaying Data Easily via ASP an...
    - Sending Email From a Form in ASP
    - Adding Member Services in ASP
    - Removing Unconfirmed Members
    - Trapping HTTP 500.100 - Internal Server Error
    - So Many Rows, So Little Time! - Case Study
    - XDO: An XML Engine Class for Classic ASP
    - Credit Card Fraud Prevention Using ASP and C...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway