Skip to content
Myr

pdf.go

This file

Path

render/pdf.go

26 lines · 651 bytes · Go

Last changed by

feat(render): add PDF renderer and tests (#4491)Aum Patelbefore adoption052d1a7

History of this file

Take it

1// Copyright 2026 Gin Core Team. All rights reserved.2// Use of this source code is governed by a MIT style3// license that can be found in the LICENSE file.45package render67import "net/http"89// PDF contains the given PDF binary data.10type PDF struct {11	Data []byte12}1314var pdfContentType = []string{"application/pdf"}1516// Render (PDF) writes PDF data with custom ContentType.17func (r PDF) Render(w http.ResponseWriter) error {18	r.WriteContentType(w)19	_, err := w.Write(r.Data)20	return err21}2223// WriteContentType (PDF) writes PDF ContentType for response.24func (r PDF) WriteContentType(w http.ResponseWriter) {25	writeContentType(w, pdfContentType)26}