func (VS *Server) generatePDFfromURL(c *gin.Context, URL string, directoryToSave string, id bson.ObjectId) {
	// Create new PDF generator
	pdfg, err := pdf.NewPDFGenerator()
	if err != nil {
		log.Fatal(err)
	}

	// Set global options
	pdfg.Dpi.Set(300)
	pdfg.Orientation.Set(pdf.OrientationLandscape)

	// Create a new input page from an URL
	page := pdf.NewPage(URL)

	// Set options for this page
	page.FooterRight.Set("[page]")
	page.FooterFontSize.Set(10)
	page.Zoom.Set(0.95)

	// Add to document
	pdfg.AddPage(page)

	// Create PDF document in internal buffer
	err = pdfg.Create()
	if err != nil {
		log.Fatal(err)
	}

	// Write buffer contents to file on disk
	name := id.Hex() + ".pdf"
	wholePath := basePath + directoryToSave + "/" + name
	err = pdfg.WriteFile(wholePath)
	if err != nil {
		os.MkdirAll(basePath+directoryToSave, os.ModePerm)
		err = pdfg.WriteFile(wholePath)
		if err != nil {
			log.Fatal(err)
		}
	}
}
//******* OLD METHOD, this is related with wkhtmltopdf but gives problems with docker, even tho the methods works in macOS perfectly with wkhtmltopdf installed  ************//
// Generates a PDF given the URL and stores it in the given PATH
OLD METHOD, this is related with wkhtmltopdf but gives problems with docker, even tho the methods works in macOS perfectly with wkhtmltopdf installed
Generates a PDF given the URL and stores it in the given PATH
// ******* OLD METHOD this is related with wkhtmltopdf but gives problems with docker even tho the methods works in macOS perfectly with wkhtmltopdf installed ************ // // Generates a PDF given the URL and stores it in the given PATH
func (VS *Server) generatePDFfromURL(c *gin.Context, URL string, directoryToSave string, id bson.ObjectId) {
	pdfg, err := pdf.NewPDFGenerator()
	if err != nil {
		log.Fatal(err)
	}
	pdfg.Dpi.Set(300)
	pdfg.Orientation.Set(pdf.OrientationLandscape)
	page := pdf.NewPage(URL)
	page.FooterRight.Set("[page]")
	page.FooterFontSize.Set(10)
	page.Zoom.Set(0.95)
	pdfg.AddPage(page)
	err = pdfg.Create()
	if err != nil {
		log.Fatal(err)
	}
	name := id.Hex() + ".pdf"
	wholePath := basePath + directoryToSave + "/" + name
	err = pdfg.WriteFile(wholePath)
	if err != nil {
		os.MkdirAll(basePath+directoryToSave, os.ModePerm)
		err = pdfg.WriteFile(wholePath)
		if err != nil {
			log.Fatal(err)
		}
	}
}
func ( VS * Server ) generatePDFfromURL ( c * gin . Context , URL string , directoryToSave string , id bson . ObjectId ) { pdfg , err := pdf . NewPDFGenerator ( ) if err != nil { log . Fatal ( err ) } pdfg . Dpi . Set ( 300 ) pdfg . Orientation . Set ( pdf . OrientationLandscape ) page := pdf . NewPage ( URL ) page . FooterRight . Set ( " " ) page . FooterFontSize . Set ( 10 ) page . Zoom . Set ( 0.95 ) pdfg . AddPage ( page ) err = pdfg . Create ( ) if err != nil { log . Fatal ( err ) } name := id . Hex ( ) + " " wholePath := basePath + directoryToSave + " " + name err = pdfg . WriteFile ( wholePath ) if err != nil { os . MkdirAll ( basePath + directoryToSave , os . ModePerm ) err = pdfg . WriteFile ( wholePath ) if err != nil { log . Fatal ( err ) } } }
OLD METHOD, this is related with wkhtmltopdf but gives problems with docker, even tho the methods works in macOS perfectly with wkhtmltopdf installed
Generates a PDF given the URL and stores it in the given PATH
OLD METHOD this is related with wkhtmltopdf but gives problems with docker even tho the methods works in macOS perfectly with wkhtmltopdf installed Generates a PDF given the URL and stores it in the given PATH
// Create new PDF generator // Set global options // Create a new input page from an URL // Set options for this page // Add to document // Create PDF document in internal buffer // Write buffer contents to file on disk