Create PDF from HTML

New Here ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

We have created a document in HTML and used CSS to resize it to the size of an A5 document. If we call the API via the create request and set the key "contentAnalyzerRequests" in the body with the following value:

 

{
	"cpf:inputs": {
		"params": {
			"cpf:inline": {
				"print": {
					"includeHeaderFooter": true
				},
				"pageLayout": {
					"pageHeight": 5.8,
					"pageWidth": 8.3
				},
				"json": "{\"k1\": \"v1\", \"k2\": \"v2\"}"
			}
		},
		"documentIn": {
			"cpf:location": "InputFile0",
			"dc:format": "application/zip"
		}
	},
	"cpf:engine": {
		"repo:assetId": "urn:aaid:cpf:Service-e2ee120a2b06427cb449592f5db967e7"
	},
	"cpf:outputs": {
		"documentOut": {
			"cpf:location": "multipartLabelOut",
			"dc:format": "application/pdf"
		}
	}
}

We get the following response back:

{
	"cpf:inputs": {
		"params": {
			"cpf:inline": {
				"print": {
					"includeHeaderFooter": true
				},
				"pageLayout": {
					"pageHeight": 5.8,
					"pageWidth": 8.3
				},
				"json": "{\"k1\": \"v1\", \"k2\": \"v2\"}"
			}
		},
		"documentIn": {
			"cpf:location": "InputFile0",
			"dc:format": "application/zip"
		}
	},
	"cpf:engine": {
		"repo:assetId": "urn:aaid:cpf:Service-e2ee120a2b06427cb449592f5db967e7"
	},
	"cpf:outputs": {
		"documentOut": {
			"cpf:location": "multipartLabelOut",
			"dc:format": "application/pdf"
		}
	}
}

 

but then when we do the get-reuqest "poll" we get the PDF document as an A4 document. The upper half is our desired content and below it a white-gray block to fill the A4 document. Here is the response of the pull-request:

 

{
   "cpf:inputs":{
      "params":{
         "cpf:inline":{
            "print":{
               "includeHeaderFooter":true
            },
            "pageLayout":{
               "pageHeight":5.8,
               "pageWidth":8.3
            },
            "json":"{\"k1\": \"v1\", \"k2\": \"v2\"}"
         }
      },
      "documentIn":{
         "cpf:location":"InputFile0",
         "dc:format":"application/zip"
      }
   },
   "cpf:engine":{
      "repo:assetId":"urn:aaid:cpf:Service-e2ee120a2b06427cb449592f5db967e7"
   },
   "cpf:status":{
      "completed":true,
      "type":"",
      "status":200
   },
   "cpf:outputs":{
      "documentOut":{
         "cpf:location":"multipartLabelOut",
         "dc:format":"application/pdf"
      }
   }
}
TOPICS
Document Generation API, PDF Tools API

Views

27

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation