troubleshooting Question

ITextSharp Binary Data issue

Avatar of rowmark
rowmark asked on
Visual Basic.NET.NET Programming
11 Comments1 Solution1408 ViewsLast Modified:

I have a crystal report in my application and I am programmatically trying to create a pdf from that using ItextSharp. I do understand that from Crystal report you can export the report to pdf.

The reason I am again doing it from iTextSharp is that I need to embedd some javaScript into the pdf as shown in my code.

The problem I am facing is, I don't know how to add the binary data from the report into the                 doc.Add(New Paragraph(blob ))

If I just write a string value inot                 doc.Add(New Paragraph("Please print pdf" )) it is working absolutely fine.

Thanks in advance
Dim blob As Byte()
Dim rpt As ReportDocument = New ReportDocument()
Dim strStream As New  _
Dim doc As New Document()
                Dim js As New StringBuilder
                Dim pdf As String = "c:\Print2Printer.pdf"
                Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream(pdf, FileMode.Create))
                js.Append("var pp = this.getPrintParams();")
                js.Append("var iCopies = 2;")
                js.Append("pp.interactive = pp.constants.interactionLevel.silent;")
                js.Append("for ( var i = 0; i < 3; i++ ) { pp.firstPage = i; pp.lastPage = i;")
                Dim jaction As PdfAction = PdfAction.JavaScript(js.ToString(), writer)
                doc.Add(New Paragraph(blob ))
                rpt = Nothing

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros