none
FPDF.Net class - Error RRS feed

  • Question

  • I don't know if anyone can help me as the writer of this class doesn't seem to answer my emails.
    I am trying to use FPDF .NET which I found on Sourceforge and I want to add to the fonts that the writer produced when he wrote it. (Code is at https://sourceforge.net/p/fpdfnet/code/HEAD/tree).

    The fonts that the writer  produced work OK, but I have converted a font that I want to use, but it does not work.  It produces an error in the program.

    I have searched through the font file that I produced, but can't see any quote characters.  I replace the ' and " with their ascii chr values, so that they would not get confused.

    The class code can be found on the link above, the code that I am using to generate the PDF is below:

    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim pdf As New FPDFnet
            pdf.AddPage("L")
            pdf.SetXY(170, 60)
            pdf.SetFont("frscript", "", 20)
            pdf.MultiCell(120, 10, "May you always have lots of old memories 
    and many more young hopes. 
    Happy Birthday ", 0, "C")
            pdf.Output("tutorial1.pdf")
            System.Diagnostics.Process.Start _
           (Application.StartupPath + "\tutorial1.pdf")
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    
            Dim fpdf As New FPDFnet
    
    
            AddHandler fpdf.header, Sub(ByRef pdf As FPDFnet)
                                        pdf.image("logo_pb.png", 20, 8, 33)
                                        pdf.SetFont("Arial", "B", 15)
                                        pdf.Cell(80)
                                        pdf.Cell(30, 10, "Title", 1, 0, "C")
                                        pdf.Ln(20)
                                    End Sub
    
            AddHandler fpdf.footer, Sub(ByRef pdf As FPDFnet)
                                        pdf.SetY(-15)
                                        pdf.SetFont("times", "", 8)
                                        pdf.Cell(0, 10, "Page " + CStr(pdf.PageNo()) + "/{nb}", 0, 0, "C")
                                    End Sub
    
    
    
            fpdf.AliasNbPage()
            fpdf.AddPage()
            fpdf.SetFont("Times", "", 12)
            For i As Integer = 1 To 40
                fpdf.Cell(0, 10, "Imprimiendo línea número " + CStr(i), 0, 1)
            Next
            fpdf.Output("tutorial2.pdf")
            System.Diagnostics.Process.Start _
           (Application.StartupPath + "\tutorial2.pdf")
        End Sub
    End Class

    I am using Tutorial 1 and the font file is called frscript.  Here is the definition file, they are text files, and have suffix .vbf:

    key=frscript
    cw=chr(0),1000,chr(1),1000,chr(2),1000,chr(3),1000,chr(4),1000,chr(5),1000,chr(6),1000,chr(7),1000,chr(8),1000,chr(9),1000,chr(10),1000,chr(11),1000,chr(12),1000,chr(13),1000,chr(14),1000,chr(15),1000,chr(16),1000,chr(17),1000,chr(18),1000,chr(19),1000,chr(20),1000,chr(21),1000,chr(22),1000,chr(23),1000,chr(24),1000,chr(25),1000,chr(26),1000,chr(27),1000,chr(28),1000,chr(29),1000,chr(30),1000,chr(31),1000, ,250,!,281,"""",260,#,615,$,365,%,667,&,646,\,135,(,188,),188,*,365,+,615,chr(44),188,-,188,.,188,/,490,0,365,1,365,2,365,3,365,4,365,5,365,6,365,7,365,8,365,9,365,:,188,;,188,<,615,=,615,>,615,?,427,@,917,A,510,B,677,C,469,D,698,E,521,F,552,G,521,H,802,I,521,J,469,K,813,L,573,M,979,N,875,O,573,P,542,Q,573,R,740,S,573,T,521,U,740,V,667,W,833,X,646,Y,698,Z,542,[,188,\,490,],188,^,562,_,500,,333,a,344,b,333,c,250,d,302,e,260,f,198,g,354,h,354,i,188,j,198,k,375,l,188,m,479,n,333,o,313,p,344,q,344,r,240,s,260,t,219,u,344,v,271,w,385,x,323,y,344,z,292,{,438,|,479,},438,~,667,chr(127),1000,chr(128),370,chr(129),1000,chr(130),188,chr(131),396,chr(132),333,chr(133),1000,chr(134),438,chr(135),438,chr(136),333,chr(137),938,chr(138),573,chr(139),250,chr(140),958,chr(141),1000,chr(142),542,chr(143),1000,chr(144),1000,chr(145),188,chr(146),188,chr(147),333,chr(148),375,chr(149),281,chr(150),365,chr(151),740,chr(152),333,chr(153),906,chr(154),260,chr(155),250,chr(156),458,chr(157),1000,chr(158),292,chr(159),698,chr(160),250,chr(161),281,chr(162),365,chr(163),375,chr(164),615,chr(165),563,chr(166),479,chr(167),469,chr(168),333,chr(169),771,chr(170),260,chr(171),385,chr(172),667,chr(173),188,chr(174),760,chr(175),500,chr(176),344,chr(177),615,chr(178),240,chr(179),240,chr(180),333,chr(181),458,chr(182),479,chr(183),188,chr(184),333,chr(185),240,chr(186),240,chr(187),385,chr(188),574,chr(189),573,chr(190),574,chr(191),427,chr(192),510,chr(193),510,chr(194),510,chr(195),510,chr(196),510,chr(197),510,chr(198),833,chr(199),469,chr(200),521,chr(201),521,chr(202),521,chr(203),521,chr(204),521,chr(205),521,chr(206),521,chr(207),521,chr(208),698,chr(209),875,chr(210),573,chr(211),573,chr(212),573,chr(213),573,chr(214),573,chr(215),615,chr(216),573,chr(217),740,chr(218),740,chr(219),740,chr(220),740,chr(221),699,chr(222),574,chr(223),375,chr(224),344,chr(225),344,chr(226),344,chr(227),344,chr(228),344,chr(229),344,chr(230),438,chr(231),250,chr(232),260,chr(233),260,chr(234),260,chr(235),260,chr(236),188,chr(237),188,chr(238),188,chr(239),188,chr(240),302,chr(241),333,chr(242),313,chr(243),313,chr(244),313,chr(245),313,chr(246),313,chr(247),615,chr(248),313,chr(249),344,chr(250),344,chr(251),344,chr(252),344,chr(253),344,chr(254),344,chr(255),344
    The original code was written 9 years ago, andI can't get any help from the author.

    ANY help would be appreciated, as I am still learning and do not have the expertise to debug this!


    TEH

    Saturday, April 6, 2019 4:05 PM

All replies

  • Hello,

    I would recommend asking in their discussion forum,

    https://sourceforge.net/p/fpdfnet/discussion/


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Saturday, April 6, 2019 4:35 PM
  •  It produces an error in the program.

    I have searched through the font file that I produced, but can't see any quote characters.  I replace the ' and " with their ascii chr values, so that they would not get confused.

     Here is the definition file, they are text files, and have suffix .vbf:

    key=frscript
    cw=chr(0),1000,chr(1),1000,chr(2),1000,chr(3),1000,chr(4),1000,chr(5),1000,chr(6),1000,chr(7),1000,chr(8),1000,chr(9),1000,chr(10),1000,chr(11),1000,chr(12),1000,chr(13),1000,chr(14),1000,chr(15),1000,chr(16),1000,chr(17),1000,chr(18),1000,chr(19),1000,chr(20),1000,chr(21),1000,chr(22),1000,chr(23),1000,chr(24),1000,chr(25),1000,chr(26),1000,chr(27),1000,chr(28),1000,chr(29),1000,chr(30),1000,chr(31),1000, ,250,!,281,"""",260,#,615,$,365,%,667,&,646,\,135,(,188,),188,*,365,+,615,chr(44),188,-,188,.,188,/,490,0,365,1,365,2,365,3,365,4,365,5,365,6,365,7,365,8,365,9,365,:,188,;,188,<,615,=,615,>,615,?,427,@,917,A,510,B,677,C,469,D,698,E,521,F,552,G,521,H,802,I,521,J,469,K,813,L,573,M,979,N,875,O,573,P,542,Q,573,R,740,S,573,T,521,U,740,V,667,W,833,X,646,Y,698,Z,542,[,188,\,490,],188,^,562,_,500,,333,a,344,b,333,c,250,d,302,e,260,f,198,g,354,h,354,i,188,j,198,k,375,l,188,m,479,n,333,o,313,p,344,q,344,r,240,s,260,t,219,u,344,v,271,w,385,x,323,y,344,z,292,{,438,|,479,},438,~,667,chr(127),1000,chr(128),370,chr(129),1000,chr(130),188,chr(131),396,chr(132),333,chr(133),1000,chr(134),438,chr(135),438,chr(136),333,chr(137),938,chr(138),573,chr(139),250,chr(140),958,chr(141),1000,chr(142),542,chr(143),1000,chr(144),1000,chr(145),188,chr(146),188,chr(147),333,chr(148),375,chr(149),281,chr(150),365,chr(151),740,chr(152),333,chr(153),906,chr(154),260,chr(155),250,chr(156),458,chr(157),1000,chr(158),292,chr(159),698,chr(160),250,chr(161),281,chr(162),365,chr(163),375,chr(164),615,chr(165),563,chr(166),479,chr(167),469,chr(168),333,chr(169),771,chr(170),260,chr(171),385,chr(172),667,chr(173),188,chr(174),760,chr(175),500,chr(176),344,chr(177),615,chr(178),240,chr(179),240,chr(180),333,chr(181),458,chr(182),479,chr(183),188,chr(184),333,chr(185),240,chr(186),240,chr(187),385,chr(188),574,chr(189),573,chr(190),574,chr(191),427,chr(192),510,chr(193),510,chr(194),510,chr(195),510,chr(196),510,chr(197),510,chr(198),833,chr(199),469,chr(200),521,chr(201),521,chr(202),521,chr(203),521,chr(204),521,chr(205),521,chr(206),521,chr(207),521,chr(208),698,chr(209),875,chr(210),573,chr(211),573,chr(212),573,chr(213),573,chr(214),573,chr(215),615,chr(216),573,chr(217),740,chr(218),740,chr(219),740,chr(220),740,chr(221),699,chr(222),574,chr(223),375,chr(224),344,chr(225),344,chr(226),344,chr(227),344,chr(228),344,chr(229),344,chr(230),438,chr(231),250,chr(232),260,chr(233),260,chr(234),260,chr(235),260,chr(236),188,chr(237),188,chr(238),188,chr(239),188,chr(240),302,chr(241),333,chr(242),313,chr(243),313,chr(244),313,chr(245),313,chr(246),313,chr(247),615,chr(248),313,chr(249),344,chr(250),344,chr(251),344,chr(252),344,chr(253),344,chr(254),344,chr(255),344

    That particular error should be easy enough to fix. In the definition file you posted above, you have not actually replaced the Quote or Apostrophe characters with their Chr() equivalents.

    So for the Quote, replace the following portion of the definition:

        !,281,"""",260,#,615

    with the Chr() equivalent:

       !,281,Chr(34),260,#,615

    or just a single Quote mark:

       !,281,",260,#,615

    As for the apostrophe, you have replaced it with a Backslash:

       &,646,\,135,(,188

    That should be:

       &,646,',135,(,188    or    &,646,Chr(39),135,(,188

    And I also notice that the Grave Accent is missing altogether:

       ^,562,_,500,,333,a,344   should be   ^,562,_,500,`,333,a,344

    They are just the mistakes I spotted after a quick scan. You should check for more yourself.

    However, once you have fixed the metrics definitions, I think you are going to run into more errors related to the font files. It looks like you should be supplying more information than just the key and cw fields in the definition file, and maybe a .z file???

    Monday, April 8, 2019 9:10 AM
  • Tried that!  The author does not answer.

    TEH

    Tuesday, April 9, 2019 1:46 PM
  • Thanks! 'could not see the wood for the trees' that cured the font file problem, however Adobe reports Bad BBox, which means there is an error in the definition, somewhere.  I have the z file in the folder, which I copied from the fonts I used with the Web PHP version of FPDF.  They are not text files and must be compiled.

    TEH

    Tuesday, April 9, 2019 1:56 PM