Comments (3)
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.
Hi @killua-eu,
I added a small example. See the En16931ReaderPdf.php in the examples folder.
Have a nice day
from zugferd.
Thanks lots!
from zugferd.
Related Issues (20)
- [QUESTION] setDocumentShipToAddress() adds no shipping data HOT 6
- [BUG] PDF Merger / Loose Comparison / adherence to PDF/A-3b / EOL marker shall be immediately followed by a % HOT 1
- [FEATURE] Add Creditor ID to addDocumentPaymentMeanToDirectDebit()? HOT 3
- Add static factory ZugferdDocumentPdfBuilder::fromPdfFile()
- Why DateTime instead of DateTimeInterface HOT 2
- [QUESTION] How to use more than 2 decimal places for prices? HOT 6
- [BUG] Wrong filename of embedded file? HOT 1
- [FEATURE] Detailed Input Value References in DocumentBuilder HOT 3
- [BUG] CountryID Rendering PROFILE_MINIMUM HOT 6
- [BUG] Error Message with PROFILE_BASIC Document Generation HOT 23
- [DOC] Documentation error at ...TaxRegistration-functions HOT 1
- [BUG] ZugferdSettings::setUnitAmountDecimals() only works for the first item HOT 4
- [FEATURE]Add the PHP requirement to the Readme HOT 1
- [BUG] BR19 Violation: Missing BG12 in XML HOT 4
- Example how to use getDocumentAdditionalReferencedDocument HOT 5
- Multiple Deprecation Warnings in 1.0.54 HOT 1
- [ENHANCEMENT] Issue with Adding Multiple BT-29 Using ->setDocumentSeller() in BASIC Profile HOT 4
- [FEATURE]Add multiple IDs for several trade parties
- Deprecated: Optional parameter $typeCode declared before required parameter HOT 2
- How to use addDocumentPositionAdditionalReferencedDocument? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zugferd.