Last active
November 21, 2020 00:02
-
-
Save jdileonardo/b2489dbad7ed720958ed5b068ce945a9 to your computer and use it in GitHub Desktop.
Spring Boot Gotenberg WebClient PDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WebClient webClient = WebClient.builder() | |
.baseUrl("http://localhost:3000/convert/url") | |
.build(); | |
MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); | |
formData.add("remoteURL", "https://google.com"); | |
formData.add("marginTop", "0"); | |
formData.add("marginBottom", "0"); | |
formData.add("marginLeft", "0"); | |
formData.add("marginRight", "0"); | |
Flux<DataBuffer> dataBufferFlux = webClient.post() | |
.contentType(org.springframework.http.MediaType.MULTIPART_FORM_DATA) | |
.body(BodyInserters.fromMultipartData(formData)) | |
.accept() | |
.retrieve() | |
.bodyToFlux(DataBuffer.class); | |
Path path = FileSystems.getDefault().getPath("target/report.pdf"); | |
DataBufferUtils.write(dataBufferFlux, path, CREATE).block(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment