PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 14, 2024 6:21 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
PostPosted: Wed Dec 31, 2014 7:21 pm 
Offline

Joined: Wed Dec 31, 2014 5:26 am
Posts: 1
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


Top
 Profile  
 
PostPosted: Thu Jan 01, 2015 12:38 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 343
Closed because it's off topic.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 48 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group