منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : كود التعامل مع مكتبة itextsharp
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم ورحمة الله وبركاتة


ارجور المساعدة بكود التعامل مع مكتبة itextsharp 


لدي برنامج يقوم بتوليد ارقام  واريد طباعة هذة الارقام في ملف pdf كل مرة في نقطة محددة من الصفحة

وعليكم السلام ورحمة الله وبركاته
يبدو لي في مثل حالتك الامر لا يحتاج اكثر من
ReportViewer
تلك المكتبة جربتها ولم تعجبني
هذا الكود لانشاء ملف واستبداله بملف جديد ضعه في حدث
Click

PHP كود :
Dim oldFile As String "SomePath/Existing.pdf"
Dim newFile As String "SomePath/New.pdf"

' Create reader
Dim reader As New PdfReader(oldFile)
Dim size As Rectangle = reader.GetPageSizeWithRotation(1)
Dim document As New Document(size)

Create the writer
Dim fs 
As New FileStream(newFileFileMode.CreateFileAccess.Write)
Dim writer As PdfWriter PdfWriter.GetInstance(documentfs)
document.Open()
Dim cb As PdfContentByte writer.DirectContent

' Set the font, color and size properties for writing text to the PDF
Dim bf As BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
cb.SetColorFill(BaseColor.DARK_GRAY)
cb.SetFontAndSize(bf, 8)

Write text in the PDF
cb
.BeginText()
Dim text As String "Some text here"

' Set the alignment and coordinates here
cb.ShowTextAligned(1, text, 520, 640, 0)
cb.EndText()

Put the text on a new page in the PDF 
Dim page 
As PdfImportedPage writer.GetImportedPage(reader1)
cb.AddTemplate(page00)

' Close the objects
document.Close()
fs.Close()
writer.Close()
reader.Close() 
(31-08-16, 12:28 AM)أبو عمر كتب : [ -> ]

وعليكم السلام ورحمة الله وبركاته
يبدو لي في مثل حالتك الامر لا يحتاج اكثر من
ReportViewer
تلك المكتبة جربتها ولم تعجبني
هذا الكود لانشاء ملف واستبداله بملف جديد ضعه في حدث
Click

PHP كود :
Dim oldFile As String "SomePath/Existing.pdf"
Dim newFile As String "SomePath/New.pdf"

' Create reader
Dim reader As New PdfReader(oldFile)
Dim size As Rectangle = reader.GetPageSizeWithRotation(1)
Dim document As New Document(size)

Create the writer
Dim fs 
As New FileStream(newFileFileMode.CreateFileAccess.Write)
Dim writer As PdfWriter PdfWriter.GetInstance(documentfs)
document.Open()
Dim cb As PdfContentByte writer.DirectContent

' Set the font, color and size properties for writing text to the PDF
Dim bf As BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
cb.SetColorFill(BaseColor.DARK_GRAY)
cb.SetFontAndSize(bf, 8)

Write text in the PDF
cb
.BeginText()
Dim text As String "Some text here"

' Set the alignment and coordinates here
cb.ShowTextAligned(1, text, 520, 640, 0)
cb.EndText()

Put the text on a new page in the PDF 
Dim page 
As PdfImportedPage writer.GetImportedPage(reader1)
cb.AddTemplate(page00)

' Close the objects
document.Close()
fs.Close()
writer.Close()
reader.Close() 
الف شكر لك اخي ابو عمر  ... جاري التجربة