问题
We have a scenario where we need to use the Quickbooks SDK to create invoices from an external application and then return a PDF copy of that invoice to the calling application.
Creating an invoice is very easy to do with the Quickbooks SDK, so there is no problem with this first step.
However, I am unsure how to actually print or return the invoice (as a PDF) through the external calling application.
Here are a few questions I have relating to this objective.
- Does the Quickbooks SDK provide the capability to directly request and return a visual representation (e.g. a PDF) of a document (e.g. an invoice)?
- Does the Quickbooks SDK provide the capability to directly print a document (e.g. an invoice)?
Most of these questions come from my general lack of familiarity with the Quickbooks SDK.
Assuming that number 1 above is not possible, some possible alternate strategies for accomplishing our objective are as follows.
Strategy A - Print and Export to PDF Using Predetermined Filename
If supported, we would request Quickbooks to print an invoice to a PDF with a name of our choosing. Using a Filewatcher, we would monitor the directory and retrieve the printed invoice programmatically.
Strategy B - Create Own Invoice Report Outside of Quickbooks
We know that we can receive all the data for the invoice back via the Quickbooks SDK. We could generate our own invoice report and print it completely outside of Quickbooks. This is a lot of work and we would prefer to avoid this if possible.
I very much welcome any comments on these strategies. Better yet, a workable solution would be great.
FYI, Our technology Stack uses C#/ASP.NET, QBFC, Web Connector, and Quickbooks 2010.
Thank you in advance!
回答1:
The answers to your questions are...:
Does the Quickbooks SDK provide the capability to directly request and return a visual representation (e.g. a PDF) of a document (e.g. an invoice)?
No, it doesn't.
Does the Quickbooks SDK provide the capability to directly print a document (e.g. an invoice)?
No, it doesn't.
Your Strategy B is the correct strategy. Grab the invoice data via the SDK, and use that to create your own invoices.
回答2:
whenever u create any invoice in quickbook using SDK, in response u will get invoice data
find below code to save invoice value in datatable
u can convert that datatable to pdf or any format
Dim response As IResponse
response = responseList.GetAt(i)
If (response.StatusCode >= 0) Then
'the request-specific response is in the details, make sure we have some
If (Not response.Detail Is Nothing) Then
'make sure the response is the type we're expecting
Dim responseType As ENResponseType
responseType = CType(response.Type.GetValue(), ENResponseType)
If (responseType = ENResponseType.rtInvoiceQueryRs) Then
'//upcast to more specific type here, this is safe because we checked with response.Type check above
Dim InvoiceRet As IInvoiceRetList
InvoiceRet = CType(response.Detail, IInvoiceRetList)
Dim row As DataRow
row = Dt.NewRow
row.Item("InvoiceNo") = InvoiceRet.GetAt(i).RefNumber.GetValue.ToString()
row.Item("ListID") = InvoiceRet.GetAt(i).TxnID.GetValue.ToString()
row.Item("EditSequence") = InvoiceRet.GetAt(i).EditSequence.GetValue.ToString()
Dt.Rows.Add(row)
End If
End If
in ur case i is 0
来源:https://stackoverflow.com/questions/7281766/how-to-export-invoices-generated-through-quickbooks-sdk-to-pdf