Announcement

Collapse
No announcement yet.

LuaHPDF + libHaru

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • LuaHPDF + libHaru

    libHaru is a free, cross platform, open source library for generating PDF files, and LuaHPDF is a module that lets you programmatically create PDF files via Lua using this library.

    LuaHPDF was developed by Kurt Jung as an interface to the Haru PDF Library. I have built libHaru 2.2.0.0, with zlib 1.2.8 and libpng 1.6.2, and finally compiled the LuaHPDF 1.3.0 module.


    A sample project features 16 different example routines, each showing different capabilities of the libHaru PDF library.

    Download: MindQuake
    Documentation: libHaru Docs

    Ulrich

  • #2
    Hi Ulrich,
    What a great tool and demo!! Awsome

    This seems to be a great tool and I would like to know if it would be possible to create a pdf out of an webpage?
    Do you happen to know that?

    Kind regards,
    Eric.

    Comment


    • #3
      If you want to print a web page as a PDF, then the normal approach would be using a PDF printer. In the installer of your product, you would include a PDF printer, like PDFlite, CutePDF or any similar product. Afterwards, you would print the content using this device, which then creates the PDF document for you.

      Ulrich

      Comment


      • #4
        This is awesome. Thanks for posting this.

        Comment


        • #5
          Ulrich,

          I don't know how much experience you have with this, but I'm a bit lost and was hoping I could ask you something.

          I've successfully made a header, body, and signature, which I'm pulling from a rich text box in AutoPlay; however, I can't figure out how to make the body text dynamically add a second page if it needs to. I'm using TextRect to draw the text, because it was the only way I could get the text to wrap.

          Comment


          • #6
            Nice work Ulrich.
            Bas Groothedde
            Imagine Programming :: Blog

            AMS8 Plugins
            IMXLH Compiler

            Comment


            • #7
              Is it possible to make bold and color font ?

              I tried this but it didnt really work ;

              hpdf.Page_BeginText(page)
              hpdf.Page_SetTextRenderingMode(page, "HPDF_FILL")
              hpdf.Page_MoveTextPos(page, 138, hpdf.Page_GetHeight (page) - 862)
              hpdf.Page_SetTextLeading(page, 12)
              hpdf.Page_ShowText(page, "JANUARY")
              hpdf.Page_EndText(page)

              Comment


              • #8
                For bold text, use a bold font name, like "Helvetica-Bold", etc. or load a TTF corresponding to a bold font, with LoadTTFontFromFile().

                The "Text" button of the demo shows how to make colored text on the page, use the Page_SetRGBFill() function.

                Click image for larger version

Name:	SNAG-2013-06-26-02.png
Views:	1
Size:	268.7 KB
ID:	284002

                Ulrich

                Comment


                • #9
                  Thanks alot Ulrich

                  Comment


                  • #10
                    how would be possible to center or right align the text in Rectangle ?

                    Code:
                    	hpdf.Page_GSave(page)  	
                                  hpdf.Page_Rectangle(page, 135, hpdf.Page_GetHeight (page) - 870, 100, 25) 
                    	hpdf.Page_Clip(page)
                    	hpdf.Page_Stroke(page)
                    	hpdf.Page_SetFontAndSize(page, font2, 13)
                    	
                    	hpdf.Page_BeginText(page)
                    	hpdf.Page_MoveTextPos(page, 138, hpdf.Page_GetHeight (page) - 862)
                    	hpdf.Page_SetTextLeading(page, 12)
                    	hpdf.Page_ShowText(page, "JANUARY")
                    	hpdf.Page_EndText(page)
                    	hpdf.Page_GRestore(page)

                    Comment


                    • #11
                      I am tring to list data in my xml file to pdf but it is coming over eachother as seen in the screenshot, why is that ?




                      Xml data:
                      Code:
                      <root><coming>
                      <person><name>TEST 1 </name><surname>ROP1</surname><company>INDIGO1</company><date>21.06.2013</date></person>
                      <person><name>TEST 2</name><surname>ROP2</surname><company>INDIGO2</company><date>22.06.2013</date></person>
                      <person><name>TEST 3</name><surname>ROP3</surname><company>INDIGO3</company><date>23.06.2013</date></person>
                      </coming></root>

                      Code :
                      Code:
                      n_lx = XML.Count("root/coming", "person");
                      local t_Links = {};
                      for i = 1, n_lx do
                        local s_xml_subpath = "root/coming/person:"..i.."/";
                        local name = XML.GetValue(s_xml_subpath.."name");
                        local surname = XML.GetValue(s_xml_subpath.."surname");
                        local company = XML.GetValue(s_xml_subpath.."company");
                        local date = XML.GetValue(s_xml_subpath.."date");
                      	hpdf.Page_GSave(page)  	
                          hpdf.Page_Rectangle(page, 1450, hpdf.Page_GetHeight (page) - 150, 280, 100)    
                      	hpdf.Page_Clip(page)
                      	hpdf.Page_Stroke(page)
                      	hpdf.Page_SetFontAndSize(page, font, 10)
                      	
                      	hpdf.Page_BeginText(page)
                      	hpdf.Page_SetRGBFill(page, 0.1, 0.5, 0.1)
                      	hpdf.Page_MoveTextPos(page, 1528, hpdf.Page_GetHeight (page) - 70)
                      	hpdf.Page_SetTextLeading(page, 12)
                      	hpdf.Page_ShowText(page, name)
                      	hpdf.Page_ShowTextNextLine(page, surname)
                      	hpdf.Page_ShowTextNextLine(page, company)
                      	hpdf.Page_ShowTextNextLine(page, date)
                      	hpdf.Page_EndText(page)
                      	hpdf.Page_GRestore(page)
                      
                      end

                      Comment


                      • #12
                        You should not call Page_MoveTextPos() inside the loop.

                        Please refrain from sending PMs regarding open discussions.

                        Ulrich

                        Comment


                        • #13
                          Yes but if i dont use Page_MoveTextPos() in loop how will I loop the text position ?

                          Comment


                          • #14
                            Why is it asking if i want to save the pdf ?
                            It is already saved ;

                            local res = hpdf.SaveToFile(pdf, "c:\\Test.pdf");
                            hpdf.Free(pdf)

                            Comment


                            • #15
                              thank you very much

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎