Coder Social home page Coder Social logo

Comments (3)

horstoeko avatar horstoeko commented on August 27, 2024

Here's what you can do:

Please use the static method readAndGuessFromFile of the class ZugferdDocumentPdfReader in the following way:

$document = ZugferdDocumentPdfReader::readAndGuessFromFile("/path/to/invoice.pdf");

You will get back an instance of the class ZugferdDocument. If something went wrong, the return value is "null".

Then use the methods firstDocumentPosition and nextDocumentPosition of $document in a loop. These methods return a boolean value when data is found. Within the loop, you can use all methods that start with "getDocumentPosition" to retrieve information, for example getDocumentPositionGenerals and so on.

Unfortunately, I never provided an example of this - sorry about that. I will try to do so as soon as possible. However, I am currently on holiday and don't have a computer with me on which I could develop something appropriate.

Alternatively, I can recommend that you look in the test folder. Just search there for the methods of $document I mentioned above.

I hope that I have been able to help you.

Regards, Daniel

EDIT: I coded a small sample on my smartphone

<?php

use horstoeko\zugferd\ZugferdDocumentPdfReader;

require "./vendor/autoload.php";

$document = ZugferdDocumentPdfReader::readAndGuessFromFile("./invoice.pdf");

if ($document->firstDocumentPosition()) {
    do
    {
        $document->getDocumentPositionGenerals($lineid, $linestatuscode, $linestatusreasoncode);
        $document->getDocumentPositionProductDetails($prodname, $proddesc, $prodsellerid, $prodbuyerid, $prodglobalidtype, $prodglobalid);
        $document->getDocumentPositionGrossPrice($grosspriceamount, $grosspricebasisquantity, $grosspricebasisquantityunitcode);
        $document->getDocumentPositionNetPrice($netpriceamount, $netpricebasisquantity, $netpricebasisquantityunitcode);
        $document->getDocumentPositionLineSummation($lineTotalAmount, $totalAllowanceChargeAmount);
        $document->getDocumentPositionQuantity($billedquantity, $billedquantityunitcode, $chargeFreeQuantity, $chargeFreeQuantityunitcode, $packageQuantity, $packageQuantityunitcode);

        echo "Line Id:                        {$lindeid}\r\n";
        echo "Product Name:                   {$prodname}\r\n";
        echo "Product Description:            {$proddesc}\r\n";
        echo "Product Buyer ID:               {$prodbuyerid}\r\n";
        echo "Product Gross Price:            {$grosspriceamount}\r\n";
        echo "Product Gross Price Basis Qty.: {$grosspricebasisquantity} {$grosspricebasisquantityunitcode}\r\n";
        echo "Product Net Price:              {$netpriceamount}\r\n";
        echo "Product Net Price Basis Qty.:   {$netpricebasisquantity} {$netpricebasisquantityunitcode}\r\n";
        echo "Quantity:                       {$billedquantity} {$billedquantityunitcode}\r\n";

        if ($document->firstDocumentPositionTax()) {
            do
            {
                $document->getDocumentPositionTax($categoryCode, $typeCode, $rateApplicablePercent, $calculatedAmount, $exemptionReason, $exemptionReasonCode);
                echo "Tax category code:              {$categoryCode}\r\n";
                echo "Tax type code:                  {$typeCode}\r\n";
                echo "Tax percent:                    {$rateApplicablePercent}\r\n";
                echo "Tax amount:                     {$calculatedAmount}\r\n";
            } while ($document->nextDocumentPositionTax());
        }

        echo "Line amount:                    {$lineTotalAmount}\r\n";

        echo "\r\n\r\n";

    } while ($document->nextDocumentPosition());
}
?>

from zugferd.

horstoeko avatar horstoeko commented on August 27, 2024

Hi @killua-eu,

I added a small example. See the En16931ReaderPdf.php in the examples folder.

Have a nice day

from zugferd.

killua-eu avatar killua-eu commented on August 27, 2024

Thanks lots!

from zugferd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.