Results 1 to 7 of 7

Thread: Creating MANY PDF's with ASP.Net

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Creating MANY PDF's with ASP.Net

    I am going to have many users running requests for an ASP.Net web service to create reports in PDF format.

    I need to make sure that each user is getting a specifically named PDF file - to handle the obvious problems of concurrency...

    I've played with settings in CutePDF, DocuCom(ScanSoft) and Adobe PDF drivers - none of them seem to have the type of low-level control I need. I've even fooled with mapped drives to different folders...

    Basically when the web service request comes into ASP.Net I want to somehow assign a "name" or "folder" for the production of that PDF file. The PDF will be created by an old VB6 app running in a BAT file (started with PROCESS.START).

    Process.Start DOES start a process that won't hang IIS - right???

    I've asked a related question in the .Net forum - under this thread

    http://www.vbforums.com/showthread.php?t=671573
    Last edited by szlamany; Feb 4th, 2012 at 01:52 PM.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Creating MANY PDF's with ASP.Net

    Hello,

    Have you looked at iTextSharp?

    http://sourceforge.net/projects/itextsharp/

    As far as I am aware, you shouldn't hang up IIS with the approach that you are using, but that is solely based on an assumption, I have never went to the length of testing that assumption

    Gary

  3. #3

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Creating MANY PDF's with ASP.Net

    I did look at iTextSharp - but that did not appear to be a printer driver - but more a PDF creation tool that you integrate with your application.

    Is that not the case??

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Creating MANY PDF's with ASP.Net

    That is correct.

    You can use it to create PDF's, which is what I thought you wanted to do. Having re-read your posts though, it would appear that this is not the case You want to be able to take "something" that already prints a document and create it as a PDF, hence the printer driver. I typically miss this step out, and simply print directly to PDF using iTextSharp.

    Gary

  5. #5

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Creating MANY PDF's with ASP.Net

    Given more time - and hopefully in the future I will have that time - I'm going to take the VB6 print logic and port it to VB.Net and at that time look at using the iTextSharp-type approach of creating the .PDF directly.

    The old VB6 code used the PRINTER object - code looks like this - looping through the rows of an ADO RECORDSET. Porting it to .Net seems like a week long project and iTextSharp would add another week - argh...

    Code:
    Printer.CurrentX = lngOffsetX
    Printer.CurrentY = lngOffsetY
    
    Do While rsPrint.State <> 0
        Do While booGotRS ' rsPrint.EOF = False
            DoEvents
            booOnPage = True
            For i = 0 To rsPrint.Fields.Count - 1
                strLastRS(i, lngRS) = strRS(i, lngRS)
                strRS(i, lngRS) = rsPrint(i) & ""
            Next i
            rsPrint.MoveNext
            If rsPrint.EOF Then
                booGotRS = False
            End If
            If prtHeader = 0 Then prtLine = 1
            For i = 1 To prtCount ' Loop though report elements
    .
    .
    .
                If booDoPrint Then
                    If prtItems(i, 1) <> 25 Then booSuppressNextTotal = False
                    gModal = True
                    Select Case prtItems(i, 1)
                        Case 1
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  Font="; strItem(prtItems(i, 7))
                            Printer.Font = strItem(prtItems(i, 7))
                        Case 2
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  Fontsize="; prtItems(i, 2)
                            Printer.FontSize = prtItems(i, 2)
                            If lngCurFontSize < Int(prtItems(i, 2) * 1.2) Then
                                lngCurFontSize = Int(prtItems(i, 2) * 1.2)
                            End If
                            lngLastFontSize = Int(prtItems(i, 2) * 1.2)
                        Case 3
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  Fontbold=True"
                            Printer.FontBold = True
                        Case 4
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  Fontbold=False"
                            Printer.FontBold = False
                        Case 5
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  FontItalic=True"
                            Printer.FontItalic = True
                        Case 6
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  FontItalic=False"
                            Printer.FontItalic = False
                        Case 7
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  ForeColor="; prtItems(i, 2)
                            Printer.ForeColor = prtItems(i, 2)
                        Case 8
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  FontUnderline=True"
                            Printer.FontUnderline = True
                        Case 9
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  FontUnderline=False"
                            Printer.FontUnderline = False
                        Case 10
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  Portrait"
                            If lngFPP = 0 Then
                                If booPrt Then
                                    Printer.Orientation = vbPRORPortrait
                                    If booDidPrintArea = False Or lngPrintAreaOr <> Printer.Orientation Then
                                        Call PrintArea(Printer, lngdpiX, lngdpiY, lngMarginLeft, lngMarginRight, lngMarginTop, lngMarginBottom _
                                            , lngPrintAreaHorz, lngPrintAreaVert, lngPhysHeight, lngPhysWidth)
                                        booDidPrintArea = True
                                        lngPrintAreaOr = Printer.Orientation
                                    End If
                                    Debug.Print "   PrintReport>TWIPS that cannot be touched on left = "; CLng(lngMarginLeft * Printer.TwipsPerPixelX) _
                                                                                                                        ; "  offset = "; gPrinterOffsetLeft
                                    Debug.Print "   PrintReport>TWIPS that cannot be touched on top = "; CLng(lngMarginTop * Printer.TwipsPerPixelY) _
                                                                                                                        ; "  offset = "; gPrinterOffsetTop
                                    lngOffsetX = gPrinterOffsetLeft
                                    lngOffsetY = gPrinterOffsetTop
                                End If
                                Printer.CurrentX = lngOffsetX
                                Printer.CurrentY = lngOffsetY
                            End If
                        Case 11
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  Landscape"
                            If lngFPP = 0 Then
                                If booPrt Then
                                    Printer.Orientation = vbPRORLandscape
                                    If booDidPrintArea = False Or lngPrintAreaOr <> Printer.Orientation Then
                                        Call PrintArea(Printer, lngdpiX, lngdpiY, lngMarginLeft, lngMarginRight, lngMarginTop, lngMarginBottom _
                                            , lngPrintAreaHorz, lngPrintAreaVert, lngPhysHeight, lngPhysWidth)
                                        booDidPrintArea = True
                                        lngPrintAreaOr = Printer.Orientation
                                    End If
                                    Debug.Print "   PrintReport>TWIPS that cannot be touched on left = "; CLng(lngMarginLeft * Printer.TwipsPerPixelX) _
                                                                                                                        ; "  offset = "; gPrinterOffsetLeft
                                    Debug.Print "   PrintReport>TWIPS that cannot be touched on top = "; CLng(lngMarginTop * Printer.TwipsPerPixelY) _
                                                                                                                        ; "  offset = "; gPrinterOffsetTop
                                    lngOffsetX = gPrinterOffsetLeft
                                    lngOffsetY = gPrinterOffsetTop
                                End If
                                Printer.CurrentX = lngOffsetX
                                Printer.CurrentY = lngOffsetY
                            End If
                        Case 12
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  Duplex="; prtItems(i, 2)
                            If Not booNoDuplex Then
                                If booPrt Then
                                    lngHoldDuplex = Printer.Duplex
                                    Printer.Duplex = IIf(prtItems(i, 2) = 0, vbPRDPHorizontal, vbPRDPVertical)
                                    booDidDuplex = True
                                End If
                            End If
    .
    .
    .
                        Case 40
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  tab("; prtItems(i, 2) _
                                                                        ; ") Item w/CR="; strItem(prtItems(i, 7))
                            If prtItems(i, 2) <> -1 Then Printer.CurrentX = lngOffsetX + prtItems(i, 2)
                            If prtCurCol > 1 Then Printer.CurrentX = Printer.CurrentX + (prtCurCol - 1) * prtColTwip
                            Printer.Print strItem(prtItems(i, 7));
                            Printer.CurrentY = ((Printer.CurrentY + (lngCurFontSize * 20)) \ lngTPY) * lngTPY
                            lngCurFontSize = lngLastFontSize
                            Printer.CurrentX = lngOffsetX
                            prtLine = prtLine + 1
                            If prtItems(i, 3) Then
                                For X = 1 To prtItems(i, 3)
                                    Printer.CurrentY = ((Printer.CurrentY + (lngCurFontSize * 20)) \ lngTPY) * lngTPY
                                    prtLine = prtLine + 1
                                Next X
                            End If
                        Case 41
                            Debug.Print "   PrintReport>"; i; ") x="; Printer.CurrentX; " y="; Printer.CurrentY _
                                                                        ; "  tab("; prtItems(i, 2) _
                                                                        ; ") Item wo/CR="; strItem(prtItems(i, 7))
                            If prtItems(i, 2) <> -1 Then Printer.CurrentX = lngOffsetX + prtItems(i, 2)
                            If prtCurCol > 1 Then Printer.CurrentX = Printer.CurrentX + (prtCurCol - 1) * prtColTwip
                            Printer.Print strItem(prtItems(i, 7));
    Last edited by szlamany; Feb 7th, 2012 at 05:02 AM.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Creating MANY PDF's with ASP.Net

    Hey,

    Yes, a port would probably be the "best" way to do it, but obviously, not the quickest.

    But in terms of the main question...

    Can you not simply use a GUID to identify the request, save the PDF as a file with the GUID included, and then look for the same GUID in the file name and returning the PDF?

    Gary

  7. #7

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Creating MANY PDF's with ASP.Net

    "Forcing" the filename of the PDF with the various different drivers is all too weak - some make you set a REGISTRY setting (CutePDF) - DocuCom doesn't permit it at all - it's hardwired to a single name from the PRINTER PREFERENCES of the driver. The newest Adobe PDF distiller has a whole api that you mess with - way to complicated.

    The problem I believe lies in the "separation" of the PRINT'ing PROGRAM and the DRIVER. There is no direct communication between the PRINT'ing program and the driver - even with the CutePDF registry setting I can't feel comfortable that "the registry setting" is going to be eaten by the correct PRINT'ing program instance.

    Thus I have serialized all this so only one report will run at a time on the server - it's not ideal but I am trying to cobble together my old report writer tool and make it run in the new age. The DocuCom PDF driver is only $99 - I can make my clients purchase that. CutePDF is free - that's always scared me (I've seen it fail to render BARCODE fonts!). Adobe professional is expensive (I've always gotten it from my clients - so I am unsure of the cost).

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width