How are document credits counted for the metered license?

The credits are counted per document when opening or writing out a PDF. When opening a new PDF, that always counts as 1 credit. When written out, it counts as 1 credit, unless the content is from documents that were already counted. For example, reading a PDF and writing it back out counts 1 credit.
Examples:
  • When creating a new PDF such as a report that counts as 1 credit.
  • When reading a single PDF with 100 pages and writing each page out to 100 output files, it counts as 1 credit.
  • If you are opening the same document, and performing the same operation (like read/write) will count 1 credit every time. 
NOTE: To avoid surprises, we recommend testing out the intended usage in the Free tier and measuring the usage to fully understand the consumption.

Measuring Credit Consumption

It is a good idea to measure credit consumption while establishing a use case with the metered license.  To do this, we can apply parts from the metered license loading example
Like normally we can load the metered license key in the init function
func init() {
	// To get your free API key for metered license, sign up on: https://cloud.unidoc.io
	// Make sure to be using UniPDF v3.19.1 or newer for Metered API key support.
	err := license.SetMeteredKey(`my metered api key goes here`)
	if err != nil {
		fmt.Printf("ERROR: Failed to set metered key: %v\n", err)
		fmt.Printf("Make sure to get a valid key from https://cloud.unidoc.io\n")
		panic(err)
	}
}<br>
And then in your main function, can place before and after your use case test code:
// GetMeteredState freshly checks the state, contacting the licensing server.
state, err := license.GetMeteredState()
if err != nil {
	fmt.Printf("ERROR getting metered state: %+v\n", err)
	panic(err)
}
fmt.Printf("Credits: %v\n", state.Credits)
fmt.Printf("Used credits: %v\n", state.Used)<br>
Do this before and after your own code and measure the change in state. Used before and after, to understand how many credits your code is using.
If anything is unclear or you are getting surprising results, please reach out to us.