DESKTOP EDITION CLOUD EDITION SERVER EDITION GUIDES FORUM

Generate PDF using API


#1

Using the API, we can retrieve almost anything we want from the database - including all relevant details about an invoice. We could theoretically construct a PDF using that information.

However, I’d like an API route that lets us generate it using the built-in generator that Manager uses for the PDF button. This will ensure that any PDFs generated look identical to the ones that are generated from within the app. The route would return a PDF document, rather than a JSON response.

This might be relevant: Link to Stack Overflow question


#2

I’d like to bump this topic, if possible, and bring in @lubos to have a quick look at it.

Essentially, if we can request the PDF via the API, we can also implement complex logic in our own applications to save us time generating PDFs manually.

Two main use-cases that I can think of:

  • External application caching invoice PDF, and allowing the customer to re-download whenever they want (e.g. customer portal)
  • Generate and email multiple invoices automatically at the end of the month, solving requests like this one programmatically: Multiple (20) Recurring Sales invoice mailing

#3

This could be possible in the future. Currently I’m trying to separate data model from UI so any report could be queried using API (not just raw data). It makes sense to allow API to convert PDF or send emails too.


#4

@ShaneAU

I am not a programmer so I don;t really understand how application programming interfaces work, but reading what you said it sounds like something that I might be interested in.

To explain what I am doing next month. I have hired a .net programmer to develop a customer relations portal for me. This will consist of things like IT Job Requests, Project Todo Management, IT Visits schedule etc.

On the Finances Page, I am going to have quotes, orders and invoices available for view for everyone of my clients.

If I have understood you correctly, one could use the API to create pdf’s for quotes, orders and invoices for clients and these pdf’s would be viewable in the online database. Potentially I could extract information like pictures of a specific laptop in Manager inventory onto the customer relations portal inventory and things like that.

Have I understood how api works - if so I could ask my programmer when developing the Finances and Inventory sections to look into extracting information from Manager as a lot of information on the customer portal will be in Manager.


#5

Excellent. I’m excited to see the results of these changes in the future - querying a report from the API was not something I had considered, but would certainly open up some interesting possibilities.

You will need to discuss your exact requirements with the programmer directly, after they have had a chance to look at the Manager API. That way, they can help you to determine what is / is not possible.

I am building a customer portal myself. One thing I’ve noticed is that if you access a Sales Invoice using the API, it doesn’t include details on whether or not that invoice has been paid. You will need to have the portal access payments separately if you want to calculate a customer’s current balance. Don’t assume that everything you see when you log into Manager is immediately available via the API in the same way.


#6

Well as the API is not ready yet - the CRM database is being created next month, I don’t think that there will be much point in asking the programmer to integrate with Manager right now. Particularly as he has quoted for a database where we are not pulling information from anywhere other than the calendar.

I was just wondering if the concept was valid and if so, in a couple of years time when I have more money in the budget, I can then start investigating pulling the data from Manager. I think it would be premature to do it now. But certainly sounds like a good idea in the future when little niggles like invoice paid etc is also synced.

Thank you.


#7

In the latest version (18.8.5), you can now retrieve PDF using API.

Let’s say you want to generate PDF for sales invoice. Have a look at the URL of invoice view which would be something like this…

/sales-invoice-view?Key=c738c447-d700-430b-9956-010046a32776&FileID=5fa5dd21-0ca9-4672-b242-486895c40f5e

to get PDF, just add .pdf extension to /sales-invoice-view resource so it’s:

/sales-invoice-view.pdf?Key=c738c447...


#8

Thanks, greatly appreciated. I’ll test it as soon as I can.


#9

@lubos when I generate the files this way, when I try to open then I get an error. The file seems to be corrupted. If I generate it in the classical way everything works fine.


#10

It works for me fine. So what error do you get?


#11

They just don’t open. Adobe Reader says it’s not a pdf file


#12

@Davide If you open it with a text editor does the structure look similar to other pdf files or is it grossly wrong such as an empty file


#13

It’s empty. 0K file