none
combine several reports into one pdf RRS feed

  • Question

  • I have several reports that describe an object. Each report can be several pages each. I have built a function for each report that returns a local report that contains each report. What I would like to do now is take each of those local reports put them together in the correct order as one large report and save it to a .pdf file while never once previewing the report.

    Thursday, January 5, 2012 4:32 PM

Answers

  • Having another day to work on the issue I have found that I could use PDFSHARP library in order to consolidate several pdf files. So what I did was create a pdf for each report I needed to merge as a separate pdf and then merged them. It works well enough.
    • Marked as answer by BrownRR Friday, January 6, 2012 4:43 PM
    Friday, January 6, 2012 4:43 PM

All replies

  • So after looking around I have the following code

     Private Sub CreatePDF(ByVal lrp As LocalReport)
            Try
                'Additional code in notes is attempt at streaming to EMF type
                Dim deviceInfo As String = "" 'This is for PDF
                Dim mimType As String = ""
                Dim encoding As String = ""
                Dim fileNameExt As String = ""
                Dim streamsPDF() As String = Nothing
                Dim warnings() As Microsoft.Reporting.WinForms.Warning = Nothing 'This is for PDF
                Dim bytes() As Byte = Nothing
                Dim fPath As String = "C:\DataBases\Test.pdf"
                Dim fileSW As FileStream
                bytes = lrp.Render("PDF", deviceInfo, mimType, encoding, fileNameExt, streamsPDF, warnings)

                fileSW = New System.IO.FileStream(fPath, IO.FileMode.Append, FileAccess.Write)

                fileSW.Write(bytes, 0, bytes.Length)
                fileSW.Flush()
                fileSW.Close()
                fileSW.Dispose()
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Critical, "Auto Batch PDF Error")
            End Try

    End Sub

    The issue is that if I use this to take a single report and create the pdf file it works fine no matter how many pages are in that report. So if the report is 10 pages long I get a pdf that shows the entire 10 page report. But if I use this sub to try and combine to reports into a single pdf I get a pdf thats file size is the same as if the two reports where combined but it only shows the last report that was written out to the pdf. Any suggestions?

     

    Thursday, January 5, 2012 7:31 PM
  • Having another day to work on the issue I have found that I could use PDFSHARP library in order to consolidate several pdf files. So what I did was create a pdf for each report I needed to merge as a separate pdf and then merged them. It works well enough.
    • Marked as answer by BrownRR Friday, January 6, 2012 4:43 PM
    Friday, January 6, 2012 4:43 PM