slideshare

package
v0.0.0-...-e77e161 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2018 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConverter = newDefaultConverter()

DefaultConverter used when no implementation is provided for Converter interface.

View Source
var DefaultDownloader = &defaultDownloader{}

DefaultDownloader used when no implementation is provided for Downloader interface.

View Source
var DefaultParser = &defaultParser{}

DefaultParser used when no implementation is provided for Parser interface.

DefaultSlideshareDownloader used if the default implementation of downloader, parser and converter is sufficient.

Functions

This section is empty.

Types

type Converter

type Converter interface {
	Reset()
	AddImage(r io.Reader, name string) error
	Save(w io.Writer) error
}

Converter is the interface that wraps image conversion methods.

Reset resets the internal state of the parser. It may be empty based on the implementation.

AddImage append new image to the pdf. It returns any error encountered that caused save to fail.

Save writes pdf content to an io.Writer. It returns any error encountered that caused save to fail.

type Downloader

type Downloader interface {
	Fetch(w io.Writer, url string) error
}

Downloader is the interface that wraps the basic Download method.

Download downloads html of slideshare page and writes it to a given writer. It returns any error encountered that caused download or write to fail.

type PDFDownloader

type PDFDownloader struct {
	// contains filtered or unexported fields
}

PDFDownloader manages the process of pdf creation. It uses downloader to download slideshare pages html and slide images parser to extract images urls from slideshare pages and converter to convert images into a pdf.

func NewSlideshareDownloader

func NewSlideshareDownloader(downloader Downloader, parser Parser, converter Converter) *PDFDownloader

NewSlideshareDownloader returns a new instance of PDFDownloader created from the given downloader, parser and converter.

func (*PDFDownloader) Download

func (pd *PDFDownloader) Download(url string, quality Quality, w io.Writer) error

Download downloads pdf from slideshare url with given quality and writes it to w. It returns any error encountered in download, parse or convert.

type Parser

type Parser interface {
	Images(r io.Reader, q Quality) ([]string, error)
}

Parser is the interface that wraps the basic Images method.

Images extracts image urls from the given html. It returns a slice of strings and any error encountered that caused the parser to fail.

type Quality

type Quality int

Quality represents image quality

const (
	// QualityFull best quality.
	QualityFull Quality = iota + 1

	// QualityNormal normal quality.
	QualityNormal

	// QualitySmall worst quality.
	QualitySmall
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL