-
Notifications
You must be signed in to change notification settings - Fork 40
Class ZugferdDocumentPdfMerger
Class representing the facillity adding existing XML data (file or data-string)
to an existing PDF with conversion to PDF/A
use horstoeko\zugferd\ZugferdDocumentPdfMerger;
$existingXmlFile = "/tmp/invoice_1.xml";
$existingPdfFile = "/tmp/emptypdf.pdf";
$mergeToPdf = "/tmp/fullpdf.pdf";
if (!file_exists($existingXmlFile) || !file_exists($existingPdfFile)) {
throw new \Exception("XML and/or PDF does not exist");
}
(new ZugferdDocumentPdfMerger($existingXmlFile, $existingPdfFile))
->generateDocument()
->saveDocument($mergeToPdf);
use horstoeko\zugferd\ZugferdDocumentPdfMerger;
$xmlString= "<xml>...</xml>";
$existingPdfFile = "/tmp/emptypdf.pdf";
$mergeToPdf = "/tmp/fullpdf.pdf";
if (!file_exists($existingPdfFile)) {
throw new \Exception("XML and/or PDF does not exist");
}
(new ZugferdDocumentPdfMerger($xmlString, $existingPdfFile))
->generateDocument()
->saveDocument($mergeToPdf);
use horstoeko\zugferd\ZugferdDocumentPdfMerger;
$existingXmlFile = "/tmp/invoice_1.xml";
$pdfString = "%PDF-1.4.....";
$mergeToPdf = "/tmp/fullpdf.pdf";
if (!file_exists($existingXmlFile)) {
throw new \Exception("XML and/or PDF does not exist");
}
(new ZugferdDocumentPdfMerger($existingXmlFile, $pdfString))
->generateDocument()
->saveDocument($mergeToPdf);
use horstoeko\zugferd\ZugferdDocumentPdfMerger;
$xmlString= "<xml>...</xml>";
$pdfString = "%PDF-1.4.....";
$mergeToPdf = "/tmp/fullpdf.pdf";
(new ZugferdDocumentPdfMerger($xmlString, $pdfString))
->generateDocument()
->saveDocument($mergeToPdf);
Constructor
public function __construct(string $xmlDataOrFilename, string $pdfData): void
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
xmlDataOrFilename | string | ❌ |
The XML data as a string or the full qualified path to an XML-File containing the XML-data |
pdfData | string | ❌ |
The full filename or a string containing the binary pdf data. This is the original PDF (e.g. created by a ERP system) |
Generates the final document
public function generateDocument(): static
{
}
Returns a value of type static
Saves the generated PDF document to a file
public function saveDocument(string $toFilename): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
toFilename | string | ❌ | The full qualified filename to which the generated PDF (with attachment)is stored |
Returns a value of type static
Starts a HTTP download of the generated PDF document
public function saveDocumentInline(string $toFilename): string
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
toFilename | string | ❌ |
Returns a value of type string
Returns the content of the generared PDF as a string
public function downloadString(): string
{
}
Returns a value of type string
Sets an additional creator tool (e.g. the ERP software that called the PHP library)
public function setAdditionalCreatorTool(string $additionalCreatorTool): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
additionalCreatorTool | string | ❌ | The name of the creator |
Returns a value of type static
Set the type of relationship for the XML attachment. Allowed
types are 'Data', 'Alternative' and 'Source'
public function setAttachmentRelationshipType(string $relationshipType): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
relationshipType | string | ❌ | Type of relationship |
Returns a value of type static
Set the type of relationship for the XML attachment to "Data"
public function setAttachmentRelationshipTypeToData(): static
{
}
Returns a value of type static
Set the type of relationship for the XML attachment to "Alternative"
public function setAttachmentRelationshipTypeToAlternative(): static
{
}
Returns a value of type static
Set the type of relationship for the XML attachment to "Source"
public function setAttachmentRelationshipTypeToSource(): static
{
}
Returns a value of type static
Attach an additional file to PDF. The file that is specified in $fullFilename
must exists
public function attachAdditionalFileByRealFile(
string $fullFilename,
string $displayName = '',
string $relationshipType = '',
): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
fullFilename | string | ❌ | |
displayName | string | ❌ | |
relationshipType | string | ❌ |
Returns a value of type static
Attach an additional file to PDF by a content string
public function attachAdditionalFileByContent(
string $content,
string $filename,
string $displayName = '',
string $relationshipType = '',
): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
content | string | ❌ | |
filename | string | ❌ | |
displayName | string | ❌ | |
relationshipType | string | ❌ |
Returns a value of type static
Set the the deterministic mode. This mode should only be used
for testing purposes
public function setDeterministicModeEnabled(bool $deterministicModeEnabled): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
deterministicModeEnabled | bool | ❌ |
Returns a value of type static
Set the template for the author meta information
public function setAuthorTemplate(string $authorTemplate): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
authorTemplate | string | ❌ |
Returns a value of type static
Set the template for the keyword meta information
public function setKeywordTemplate(string $keywordTemplate): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
keywordTemplate | string | ❌ |
Returns a value of type static
Set the template for the title meta information
public function setTitleTemplate(string $titleTemplate): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
titleTemplate | string | ❌ |
Returns a value of type static
Set the template for the subject meta information
public function setSubjectTemplate(string $subjectTemplate): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
subjectTemplate | string | ❌ |
Returns a value of type static
Set the user defined callback for generating custom meta information
public function setMetaInformationCallback(?callable $callback = null): static
{
}
Name | Type | Allows Null | Description |
---|---|---|---|
callback | callable | ✔️ |
Returns a value of type static