Convert PDF to Image Formats in Go
Go Convert PDF to Image
In this article, we will show you the options for converting PDF to image formats.
Previously scanned documents are often saved in the PDF file format. However, do you need to edit it in a graphic editor or send it further in image format? We have a universal tool for you to convert PDF to images using Aspose.PDF for Go via C++. The most common task is when you need to save an entire PDF document or some specific pages of a document as a set of images. Aspose.PDF for Go via C++ allows you to convert PDF to JPG and PNG formats to simplify the steps required to get your images from a specific PDF file.
Aspose.PDF for Go via C++ supports various PDF to image formats conversion. Please checks the section Aspose.PDF Supported File Formats.
Convert PDF to JPEG
The provided Go code snippet demonstrates how to convert the first page of a PDF document into a JPEG image using the Aspose.PDF library:
- Open a PDF document.
- Convert a Page to JPEG using PageToJpg function.
- Close the PDF document and release any allocated resources.
package main
import "github.com/aspose-pdf/aspose-pdf-go-cpp"
import "log"
func main() {
// Open(filename string) opens a PDF-document with filename
pdf, err := asposepdf.Open("sample.pdf")
if err != nil {
log.Fatal(err)
}
// PageToJpg(num int32, resolution_dpi int32, filename string) saves the specified page as Jpg-image file
err = pdf.PageToJpg(1, 100, "sample_page1.jpg")
if err != nil {
log.Fatal(err)
}
// Close() releases allocated resources for PDF-document
defer pdf.Close()
}
Try to convert PDF to JPEG online
Aspose.PDF for Go presents you online free application “PDF to JPEG”, where you may try to investigate the functionality and quality it works.
Convert PDF to TIFF
The provided Go code snippet demonstrates how to convert the first page of a PDF document into a TIFF image using the Aspose.PDF library:
- Open a PDF document.
- Convert a Page to TIFF using PageToTiff function.
- Close the PDF document and release any allocated resources.
package main
import "github.com/aspose-pdf/aspose-pdf-go-cpp"
import "log"
func main() {
// Open(filename string) opens a PDF-document with filename
pdf, err := asposepdf.Open("sample.pdf")
if err != nil {
log.Fatal(err)
}
// PageToTiff(num int32, resolution_dpi int32, filename string) saves the specified page as Tiff-image file
err = pdf.PageToTiff(1, 100, "sample_page1.tiff")
if err != nil {
log.Fatal(err)
}
// Close() releases allocated resources for PDF-document
defer pdf.Close()
}
Try to convert PDF to TIFF online
Aspose.PDF for Go presents you online free application “PDF to TIFF”, where you may try to investigate the functionality and quality it works.
Convert PDF to PNG
The provided Go code snippet demonstrates how to convert the first page of a PDF document into a PNG image using the Aspose.PDF library:
- Open a PDF document.
- Convert a Page to PNG using PageToPng function.
- Close the PDF document and release any allocated resources.
package main
import "github.com/aspose-pdf/aspose-pdf-go-cpp"
import "log"
func main() {
// Open(filename string) opens a PDF-document with filename
pdf, err := asposepdf.Open("sample.pdf")
if err != nil {
log.Fatal(err)
}
// PageToPng(num int32, resolution_dpi int32, filename string) saves the specified page as Png-image file
err = pdf.PageToPng(1, 100, "sample_page1.png")
if err != nil {
log.Fatal(err)
}
// Close() releases allocated resources for PDF-document
defer pdf.Close()
}
Try to convert PDF to PNG online
As an example of how our free applications work please check the next feature.
Aspose.PDF for Go presents you online free application “PDF to PNG”, where you may try to investigate the functionality and quality it works.
Scalable Vector Graphics (SVG) is a family of specifications of an XML-based file format for two-dimensional vector graphics, both static and dynamic (interactive or animated). The SVG specification is an open standard that has been under development by the World Wide Web Consortium (W3C) since 1999.
Convert PDF to SVG
The provided Go code snippet demonstrates how to convert the first page of a PDF document into a SVG image using the Aspose.PDF library:
- Open a PDF document.
- Convert a Page to SVG using PageToSvg function.
- Close the PDF document and release any allocated resources.
package main
import "github.com/aspose-pdf/aspose-pdf-go-cpp"
import "log"
func main() {
// Open(filename string) opens a PDF-document with filename
pdf, err := asposepdf.Open("sample.pdf")
if err != nil {
log.Fatal(err)
}
// PageToSvg(num int32, filename string) saves the specified page as Svg-image file
err = pdf.PageToSvg(1, "sample_page1.svg")
if err != nil {
log.Fatal(err)
}
// Close() releases allocated resources for PDF-document
defer pdf.Close()
}
Try to convert PDF to SVG online
Aspose.PDF for Go presents you online free application “PDF to SVG”, where you may try to investigate the functionality and quality it works.
Convert PDF to DICOM
The provided Go code snippet demonstrates how to convert the first page of a PDF document into a DICOM image using the Aspose.PDF library:
- Open a PDF document.
- Convert a Page to DICOM using PageToDICOM function.
- Close the PDF document and release any allocated resources.
package main
import "github.com/aspose-pdf/aspose-pdf-go-cpp"
import "log"
func main() {
// Open(filename string) opens a PDF-document with filename
pdf, err := asposepdf.Open("sample.pdf")
if err != nil {
log.Fatal(err)
}
// PageToDICOM(num int32, resolution_dpi int32, filename string) saves the specified page as DICOM-image file
err = pdf.PageToDICOM(1, 100, "sample_page1.dcm")
if err != nil {
log.Fatal(err)
}
// Close() releases allocated resources for PDF-document
defer pdf.Close()
}
Convert PDF to BMP
The provided Go code snippet demonstrates how to convert the first page of a PDF document into a BMP image using the Aspose.PDF library:
- Open a PDF document.
- Convert a Page to BMP using PageToBmp function.
- Close the PDF document and release any allocated resources.
package main
import "github.com/aspose-pdf/aspose-pdf-go-cpp"
import "log"
func main() {
// Open(filename string) opens a PDF-document with filename
pdf, err := asposepdf.Open("sample.pdf")
if err != nil {
log.Fatal(err)
}
// PageToBmp(num int32, resolution_dpi int32, filename string) saves the specified page as Bmp-image file
err = pdf.PageToBmp(1, 100, "sample_page1.bmp")
if err != nil {
log.Fatal(err)
}
// Close() releases allocated resources for PDF-document
defer pdf.Close()
}