本文介绍了我想在VB.NET中使用pdffilewriter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好, i希望在VB.net中使用PDFFileWriter,但它不起作用。 我只有空页。你有没有VB.NET 2017的例子? 这是一个很好的课程。 谢谢 好​​问候弗兰克 我尝试过: 这是我的小型测试程序:Hello,i want to use the PDFFileWriter in VB.net but it doesn't work.I have only an empty page. Have you got any examples for VB.NET 2017?It's a good class.ThanksBest regards FrankWhat I have tried:Here is my small testprogram:Imports PdfFileWriterImports System.IOImports System.DrawingPublic Class Form1 Dim ArialFont As PdfFont Dim FontSize As Double Dim Ascent As Double Dim Descent As Double Dim FontHeight2 As Double Dim Document As PdfDocument Dim CenterX As Double = 4.25 Dim CenterY As Double = 5.5 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim npfad As String = "" SaveFileDialog1.Title = "PDF speicher unter..." SaveFileDialog1.OverwritePrompt = True If SaveFileDialog1.ShowDialog = DialogResult.OK And SaveFileDialog1.FileName > "" Then npfad = SaveFileDialog1.FileName If UCase(npfad).EndsWith("PDF") = False Then npfad = npfad & ".PDF" End If Dim PDFDokument As New PdfDocument(PaperType.A4, False, UnitOfMeasure.Inch, npfad) 'PDFDokument.Debug = True Dim FontName1 As String = "Arial" Dim FontName2 As String = "Times New Roman" ArialFont = PdfFont.CreatePdfFont(PDFDokument, FontName1, FontStyle.Regular, True) Dim ArialNormal As PdfFont = PdfFont.CreatePdfFont(PDFDokument, FontName1, FontStyle.Regular, True) Dim ArialBold As PdfFont = PdfFont.CreatePdfFont(PDFDokument, FontName1, FontStyle.Bold, True) Dim ArialItalic As PdfFont = PdfFont.CreatePdfFont(PDFDokument, FontName1, FontStyle.Italic, True) Dim ArialBoldItalic As PdfFont = PdfFont.CreatePdfFont(PDFDokument, FontName1, FontStyle.Bold And FontStyle.Italic, True) Dim TimesNormal As PdfFont = PdfFont.CreatePdfFont(PDFDokument, FontName2, FontStyle.Regular, True) Dim PDFPage As New PdfPage(PDFDokument) Dim Contents As New PdfContents(PDFDokument) Dim left As Double = CenterX - 0.5 * 1 Dim Right As Double = CenterX + 0.5 * 1 Dim Top As Double = CenterY + 0.5 * 1 Dim Bottom As Double = CenterY - 0.5 * 1 Contents.DrawText(ArialFont, 10, 10, 10, TextJustify.Center, DrawStyle.Normal, Color.Black, "Hallo") ' save state Contents.SaveGraphicsState() Contents.SetLineWidth(0.1) Contents.SetColorStroking(Color.Black) Contents.SetColorNonStroking(Color.LightBlue) Contents.DrawRectangle(left, Bottom, 3, 3, PaintOp.CloseFillStroke) Contents.RestoreGraphicsState() 'PDFContents.SaveGraphicsState() 'Contents.Translate(1.1, 1.1) 'Dim TextBox As New TextBox(Width, 0.25) 'Dim PosY As Double = Height 'TextBox.AddText(ArialNormal, 10, "Hallo Welt") Dim nText As String = "Hallo Welt" Dim Breite As Double = ArialBold.TextWidth(25, nText) Dim Höhe As Double = ArialBold.LineSpacing(25) 'Stop Contents.SaveGraphicsState() Dim nBarcode As New Barcode128("2018-2928282") Contents.SetColorNonStroking(Color.Red) Contents.DrawBarcode(3, 7, 0.01, 1, nBarcode, ArialNormal, 8) Contents.SetLineWidth(0.01) Contents.BeginTextMode() Contents.SetColorStroking(Color.DarkBlue) Contents.DrawText(ArialBold, 25, 4, 9, TextJustify.Center, 0.02, Color.FromArgb(128, 0, 0, 255), Color.FromArgb(255, 255, 0, 0), "Hallo Frank") Contents.DrawLine(10, 10, 50, 20) Contents.EndTextMode() Contents.DrawRectangle(1, 1, 6, 9, PaintOp.CloseFillStroke) Contents.RestoreGraphicsState() PDFDokument.CreateFile() Process.Start(npfad) End If End SubEnd Class推荐答案Dim PDFPage As New PdfPage(PDFDokument)Dim Contents As New PdfContents(PDFDokument) toDim PDFPage As New PdfPage(PDFDokument)Dim Contents As New PdfContents(PDFPage)这是从 PDF文件编写器C#类库(版本1.20.0) [ ^ ]This is extrapolated from the example on PDF File Writer C# Class Library (Version 1.20.0)[^]// Step 3: Add new pagePage = new PdfPage(Document);// Step 4:Add contents to pageContents = new PdfContents(Page); 这篇关于我想在VB.NET中使用pdffilewriter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-31 12:53