728x90
API 호출 후 PDF 를 저장 하기 위해 사용한다 .
HttpResponseMessage response = await client.PostAsync(url, content);
string responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Response Status Code: {response.StatusCode}");
Console.WriteLine($"Response Body: {responseContent}");
// JSON 파싱
JObject jsonObj = JObject.Parse(responseContent);
string base64Content = jsonObj["documents"][0]["content"].ToString(); // content 값 가져오기
// JSON에서 content 가져오기 (Base64 인코딩된 PDF)
string filePath = "output.pdf";
byte[] pdfBytes = Convert.FromBase64String(base64Content);
File.WriteAllBytes(filePath, pdfBytes);
Console.WriteLine($"PDF 저장 완료: {filePath}");
// PDF 파일 열기 (자동 출력)
Process.Start(new ProcessStartInfo(filePath) { UseShellExecute = true });
728x90
'C#' 카테고리의 다른 글
C# Excel 파일 수정, 머지 Merge 방법 (0) | 2025.04.17 |
---|---|
C# DataTable 특정 컬럼 제거하기 (0) | 2025.04.09 |
C# 콤보박스에 값 넣기 001 ~ 999 (0) | 2024.12.02 |
C# DataTable 원하는 값 찾기 (0) | 2024.08.26 |
C# Panel, Button, Label을 이용한 동적 디자인 (0) | 2024.08.22 |