Php DocuSign-发送一个包含无限数量PDF的信封';s

Php DocuSign-发送一个包含无限数量PDF的信封';s,php,docusignapi,Php,Docusignapi,使用 我已成功实现上述存储库,以发送PDF进行签名 我试图实现的是能够发送任意数量的PDF进行签名,但示例仅允许3个文档 有关章节如下: $document1 = new \DocuSign\eSign\Model\Document([ # create the DocuSign document object 'document_base64' => $doc1_b64, 'name' => 'Order acknowledgement', # can be d

使用

我已成功实现上述存储库,以发送PDF进行签名

我试图实现的是能够发送任意数量的PDF进行签名,但示例仅允许3个文档

有关章节如下:

$document1 = new \DocuSign\eSign\Model\Document([  # create the DocuSign document object
    'document_base64' => $doc1_b64,
    'name' => 'Order acknowledgement',  # can be different from actual file name
    'file_extension' => 'html',  # many different document types are accepted
    'document_id' => '1'  # a label used to reference the doc
]);
$document2 = new \DocuSign\eSign\Model\Document([  # create the DocuSign document object
    'document_base64' => $doc2_b64,
    'name' => 'Conditions of Sale',  # can be different from actual file name
    'file_extension' => 'docx',  # many different document types are accepted
    'document_id' => '2'  # a label used to reference the doc
]);
$document3 = new \DocuSign\eSign\Model\Document([  # create the DocuSign document object
    'document_base64' => $doc3_b64,
    'name' => 'Invoice e'.$S_invoiceID.'',  # can be different from actual file name
    'file_extension' => 'pdf',  # many different document types are accepted
    'document_id' => '3'  # a label used to reference the doc
]);
         echo $document3;
# The order in the docs array determines the order in the envelope
//$envelope_definition->setDocuments([$document1, $document2, $document3]);
$envelope_definition->setDocuments([$document2, $document3]);
我尝试了以下方法,但没有效果:

$InvoiceIDArray = ["9329","9328"];

foreach ($InvoiceIDArray as $InvoiceID)  {

    $content_bytes = file_get_contents($demo_docs_path . "e".$InvoiceID."_invoice.pdf");
    $doc3_b64 = base64_encode($content_bytes);

    $document[$InvoiceID] = new \DocuSign\eSign\Model\Document([  # create the DocuSign document object
        'document_base64' => $doc3_b64,
        'name' => 'Invoice e'.$InvoiceID.'',  # can be different from actual file name
        'file_extension' => 'pdf',  # many different document types are accepted
        'document_id' => ''.$InvoiceID.''  # a label used to reference the doc
    ]);

    $this->newDocs = $document[$InvoiceID];

}

# The order in the docs array determines the order in the envelope
$envelope_definition->setDocuments([$documentA,$this->newDocs]);    
例如,我想从数组中提取ID,然后发送带有匹配ID的PDF


非常感谢您的帮助。

您的循环正在用
$this->newDocs=$document[$InvoiceID]

未经测试:

$InvoiceIDArray = ["9329","9328"];
$this->newDocs = [];

foreach ($InvoiceIDArray as $InvoiceID)  {

    $content_bytes = file_get_contents($demo_docs_path . "e".$InvoiceID."_invoice.pdf");

    if (empty($content_bytes)) { continue; } # prevent adding empty contents

    $this->newDocs[] = new \DocuSign\eSign\Model\Document([  # create the DocuSign document object
        'document_base64' => base64_encode($content_bytes),
        'name' => 'Invoice e'.$InvoiceID,  # can be different from actual file name
        'file_extension' => 'pdf',  # many different document types are accepted
        'document_id' => $InvoiceID  # a label used to reference the doc
    ]);
}

# The order in the docs array determines the order in the envelope
$envelope_definition->setDocuments(array_merge([$documentA], $this->newDocs));
还是简单一点

$invoice_ids = [9329, 9328];
$documents = [$documentA];

foreach ($invoice_ids as $invoice_id)  {
    $content_bytes = @file_get_contents("{$demo_docs_path}e{$invoice_id}_invoice.pdf");

    if (empty($content_bytes)) { continue; }

    $documents[] = new \DocuSign\eSign\Model\Document([
        'document_base64' => base64_encode($content_bytes),
        'name' => "Invoice e{$invoice_id}",
        'file_extension' => 'pdf',
        'document_id' => $invoice_id
    ]);
}

$envelope_definition->setDocuments($documents);