منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[سؤال] كود التعامل مع مكتبة itextsharp - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم مكتبة اكواد VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=185)
+--- الموضوع : [سؤال] كود التعامل مع مكتبة itextsharp (/showthread.php?tid=17085)



كود التعامل مع مكتبة itextsharp - saad mahyoub - 30-08-16

السلام عليكم ورحمة الله وبركاتة


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


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


RE: كود التعامل مع مكتبة itextsharp - أبو عمر - 31-08-16


وعليكم السلام ورحمة الله وبركاته
يبدو لي في مثل حالتك الامر لا يحتاج اكثر من
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() 



RE: كود التعامل مع مكتبة itextsharp - saad mahyoub - 01-09-16

(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() 
الف شكر لك اخي ابو عمر  ... جاري التجربة