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  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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: 3 stars3 stars3 stars3 stars3 stars / 5
    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


    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! A Layered approach to delivering security-rich Web applications

    As businesses grow increasingly dependent upon Web applications to provide services to customers, employees and partners, these complex applications become more difficult to secure. Although traditional security solutions protect Internet infrastructure layers, they do not guard against HTTP and HTML attacks. Many organizations that conduct security testing still deploy applications that allow attackers to manipulate their logic and wreak havoc on their business. To mitigate this risk, development and delivery teams must address Web application security throughout the lifecycle, addressing the many layers detailed in this paper.
    FREE! Go There Now!


    NEW! Evaluate WebSphere Extended Deployment Compute Grid V6.1

    Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points.
    FREE! Go There Now!


    NEW! IBM Rational Systems Development e-Kit

    As systems increase in complexity, communication between systems and software teams becomes more and more difficult. Now, there’s a way to improve product quality and communication.<br />Read the “Model Driven Systems Development” white paper to see how. Also included in this kit are more educational white papers, customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems.<br />
    FREE! Go There Now!


    NEW! Maintaining QoS and Process Integrity in an SOA Environment

    This webcast outlines the best practices that must be instituted to gain the maximum benefit from SOA while maintaining high quality of service. Whether you are deploying new applications or managing and monitoring your existing infrastructure, learn how you can ensure high quality of services with SOA based solutions from IBM. All registrants who attend this live Web Seminar will receive complimentary access to a white paper titled “Maintaining QoS in an SOA Environment”.
    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! Successful Change and Release Management for .NET

    Join this webcast to discover the key requirements for successful change and release management. Learn how to extend your .NET environment to improve productivity and collaboration, and address core problems afflicting team development. In this webcast, we’ll review typical challenges faced by customers and how to resolve them with the IBM Rational Change and Release Management solution, including Rational ClearCase, Rational ClearQuest and Rational Build Forge. Replay is available for 9 months.
    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: Calling All Testers! Find Application Vulnerabilities Early in the Development Process Where they are Easier to Fix and Less Risky to your Business

    In this webcast, IBM Rational will discuss the importance of Web application security and will share techniques and best practices to introduce application security testing into current QA processes including: understanding common security vulnerabilities and techniques to integrate security testing with defect tracking and remediation systems in an effort to safeguard sensitive online information.
    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-2010 by Developer Shed. All rights reserved. DS Cluster 12 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek