func (VS *Server) newPDFqrOld(c *gin.Context) {
	// Get parameters to make the PDF
	id, b := VS.getIDParamFromURL(c, "id")
	if !b {
		return
	}
	typeOfI, b := VS.getParamFromURL(c, "type")
	typeOfItem := TypeOfItem(typeOfI)
	if !b {
		return
	}
	pagesN, b := VS.getParamFromURL(c, "pages")
	pagesNumber, _ := strconv.Atoi(pagesN)
	if !b {
		return
	}
	// Change the color of the QR depending on the type of Item
	var color color.RGBA
	switch typeOfItem {
	case ServiceProduct:
		color = Pink
	case Tool:
		color = DarkBrown
	case PrimaryMaterial:
		color = Blue
	}
	var PDF PDF
	PDF.Date = time.Now().Unix()
	PDF.ID = id
	PDF.Pages = pagesNumber
	PDF.TypeOfItem = typeOfItem
	PDF.TypeOfPDF = PDFQR
	VS.addElementToDatabaseWithoutRegister(c, PDF, PDF.ID, "h_reports", "newPDFqr", "PDF.TypeOfPDF = PDFQR ")
	// We create every page of the PDF
	var QRs []QR
	var QR QR
	var imagesToHTML []string
	var PDFpages []PDFPageqrHTML
	for page := 0; page < pagesNumber; page++ {
		for i := 0; i < 108; i++ {
			// Create and add the ID
			QR.ID = bson.NewObjectId()
			QR.PDF = PDF.ID
			QR.PageNumber = page + 1
			QR.TypeOfItem = typeOfItem
			QRs = append(QRs, QR)
			VS.addElementToDatabaseWithoutRegister(c, QR, QR.ID, "h_reports", "newPDFqr", "QRs = append(QRs, QR)")
			// Create and add the QR image
			qr, err := qrcode.New(QRs[i].ID.Hex(), qrcode.High)
			qr.ForegroundColor = color
			img, err := qr.PNG(256)
			if err != nil {
				fmt.Print(err)
			}
			// Create the images for the HTML
			img2 := base64.StdEncoding.EncodeToString(img)
			imagesToHTML = append(imagesToHTML, img2)
		}
		PDFpages = append(PDFpages, getPagePDFqr(imagesToHTML, PDF))
		QRs = nil
		imagesToHTML = nil
	}
	// Here we show it in HTML to be able to make the pdf. After showing wee need to transform it in to PDF
	render(c, gin.H{
		"PDFpages": PDFpages,
	}, "new-qr.html")
}
//******* OLD METHOD, this is related with wkhtmltopdf but gives problems with docker, even tho the methods works in macOS perfectly with wkhtmltopdf installed  ************//
// PDFqr shows the HTML that shows the QR codes whenever is called and saves the ID in the DB.
// This is transparent and should be only called for converting it to PDF
OLD METHOD, this is related with wkhtmltopdf but gives problems with docker, even tho the methods works in macOS perfectly with wkhtmltopdf installed
PDFqr shows the HTML that shows the QR codes whenever is called and saves the ID in the DB.
This is transparent and should be only called for converting it to PDF
// ******* OLD METHOD this is related with wkhtmltopdf but gives problems with docker even tho the methods works in macOS perfectly with wkhtmltopdf installed ************ // // PDFqr shows the HTML that shows the QR codes whenever is called and saves the ID in the DB . // This is transparent and should be only called for converting it to PDF
func (VS *Server) newPDFqrOld(c *gin.Context) {
	id, b := VS.getIDParamFromURL(c, "id")
	if !b {
		return
	}
	typeOfI, b := VS.getParamFromURL(c, "type")
	typeOfItem := TypeOfItem(typeOfI)
	if !b {
		return
	}
	pagesN, b := VS.getParamFromURL(c, "pages")
	pagesNumber, _ := strconv.Atoi(pagesN)
	if !b {
		return
	}
	var color color.RGBA
	switch typeOfItem {
	case ServiceProduct:
		color = Pink
	case Tool:
		color = DarkBrown
	case PrimaryMaterial:
		color = Blue
	}
	var PDF PDF
	PDF.Date = time.Now().Unix()
	PDF.ID = id
	PDF.Pages = pagesNumber
	PDF.TypeOfItem = typeOfItem
	PDF.TypeOfPDF = PDFQR
	VS.addElementToDatabaseWithoutRegister(c, PDF, PDF.ID, "h_reports", "newPDFqr", "PDF.TypeOfPDF = PDFQR ")
	var QRs []QR
	var QR QR
	var imagesToHTML []string
	var PDFpages []PDFPageqrHTML
	for page := 0; page < pagesNumber; page++ {
		for i := 0; i < 108; i++ {
			QR.ID = bson.NewObjectId()
			QR.PDF = PDF.ID
			QR.PageNumber = page + 1
			QR.TypeOfItem = typeOfItem
			QRs = append(QRs, QR)
			VS.addElementToDatabaseWithoutRegister(c, QR, QR.ID, "h_reports", "newPDFqr", "QRs = append(QRs, QR)")
			qr, err := qrcode.New(QRs[i].ID.Hex(), qrcode.High)
			qr.ForegroundColor = color
			img, err := qr.PNG(256)
			if err != nil {
				fmt.Print(err)
			}
			img2 := base64.StdEncoding.EncodeToString(img)
			imagesToHTML = append(imagesToHTML, img2)
		}
		PDFpages = append(PDFpages, getPagePDFqr(imagesToHTML, PDF))
		QRs = nil
		imagesToHTML = nil
	}
	render(c, gin.H{
		"PDFpages": PDFpages,
	}, "new-qr.html")
}
func ( VS * Server ) newPDFqrOld ( c * gin . Context ) { id , b := VS . getIDParamFromURL ( c , " " ) if ! b { return } typeOfI , b := VS . getParamFromURL ( c , " " ) typeOfItem := TypeOfItem ( typeOfI ) if ! b { return } pagesN , b := VS . getParamFromURL ( c , " " ) pagesNumber , _ := strconv . Atoi ( pagesN ) if ! b { return } var color color . RGBA switch typeOfItem { case ServiceProduct : color = Pink case Tool : color = DarkBrown case PrimaryMaterial : color = Blue } var PDF PDF PDF . Date = time . Now ( ) . Unix ( ) PDF . ID = id PDF . Pages = pagesNumber PDF . TypeOfItem = typeOfItem PDF . TypeOfPDF = PDFQR VS . addElementToDatabaseWithoutRegister ( c , PDF , PDF . ID , " " , " " , " " ) var QRs [ ] QR var QR QR var imagesToHTML [ ] string var PDFpages [ ] PDFPageqrHTML for page := 0 ; page < pagesNumber ; page ++ { for i := 0 ; i < 108 ; i ++ { QR . ID = bson . NewObjectId ( ) QR . PDF = PDF . ID QR . PageNumber = page + 1 QR . TypeOfItem = typeOfItem QRs = append ( QRs , QR ) VS . addElementToDatabaseWithoutRegister ( c , QR , QR . ID , " " , " " , " " ) qr , err := qrcode . New ( QRs [ i ] . ID . Hex ( ) , qrcode . High ) qr . ForegroundColor = color img , err := qr . PNG ( 256 ) if err != nil { fmt . Print ( err ) } img2 := base64 . StdEncoding . EncodeToString ( img ) imagesToHTML = append ( imagesToHTML , img2 ) } PDFpages = append ( PDFpages , getPagePDFqr ( imagesToHTML , PDF ) ) QRs = nil imagesToHTML = nil } render ( c , gin . H { " " : PDFpages , } , " " ) }
OLD METHOD, this is related with wkhtmltopdf but gives problems with docker, even tho the methods works in macOS perfectly with wkhtmltopdf installed
PDFqr shows the HTML that shows the QR codes whenever is called and saves the ID in the DB.
OLD METHOD this is related with wkhtmltopdf but gives problems with docker even tho the methods works in macOS perfectly with wkhtmltopdf installed PDFqr shows the HTML that shows the QR codes whenever is called and saves the ID in the DB .
// Get parameters to make the PDF // Change the color of the QR depending on the type of Item // We create every page of the PDF // Create and add the ID // Create and add the QR image // Create the images for the HTML // Here we show it in HTML to be able to make the pdf. After showing wee need to transform it in to PDF