PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
unable to compile itextsharp demo https://forum.pdfsharp.net/viewtopic.php?f=2&t=3020 |
Page 1 of 1 |
Author: | bartj [ Wed Dec 31, 2014 7:21 pm ] |
Post subject: | unable to compile itextsharp demo |
Hello, I am attempting to run a simple demo program using itextsharp. The code is shown below. Am unable to compile the following line: Dim pdfDoc As New iTextSharp.text.pdf.PdfDocument(PageSize.LETTER, 10.0F, 10.0F, 10.0F, 0.0F) "pdfDoc" is underlined and the message when hovering is: iTextSharp.text.pdf.friend Sub New()' is not accessible in this context because it is 'Friend'. This line is in the code section where we write to a stream. Any ideas on how to get this to work? (Am using VS2010 on win7) thanks, bartj Imports iTextSharp.text Imports iTextSharp.text.pdf Imports iTextSharp.text.pdf.PdfPCell Imports iTextSharp.text.pdf.PdfPTable Imports iTextSharp.text.pdf.PdfImage Imports System.IO Module itxtsharp Sub sharptest() Dim pdfTable As New iTextSharp.text.pdf.PdfPTable(5) '''''''''''''''''''''''''''''''''''''''''''''''''' pdfTable.DefaultCell.Padding = 3 pdfTable.WidthPercentage = 30 pdfTable.HorizontalAlignment = iTextSharp.text.Element.ALIGN_LEFT pdfTable.DefaultCell.BorderWidth = 1 'Adding Header row For Each column As Windows.Forms.DataGridViewColumn In Form1.DataGridViewPeak.Columns Dim cell As New PdfPCell(New iTextSharp.text.Phrase(column.HeaderText)) cell.BackgroundColor = New iTextSharp.text.Color(240, 240, 240) pdfTable.AddCell(cell) Next 'Adding DataRow For Each row As Windows.Forms.DataGridViewRow In Form1.DataGridViewPeak.Rows For Each cell As Windows.Forms.DataGridViewCell In row.Cells pdfTable.AddCell(cell.Value.ToString()) Next Next 'Exporting to PDF Dim folderPath As String = "C:\PDFs\" If Not Directory.Exists(folderPath) Then Directory.CreateDirectory(folderPath) End If Using stream As New FileStream(folderPath & "DataGridViewExport.pdf", FileMode.Create) Dim pdfDoc As New iTextSharp.text.pdf.PdfDocument(PageSize.LETTER, 10.0F, 10.0F, 10.0F, 0.0F) '<<<<<<here is where the problem occurs PdfWriter.GetInstance(pdfDoc, stream) pdfDoc.Open() pdfDoc.Add(pdfTable) pdfDoc.Close() stream.Close() End Using End Sub End Module |
Author: | () => true [ Thu Jan 01, 2015 12:38 pm ] |
Post subject: | Re: unable to compile itextsharp demo |
Closed because it's off topic. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |