Append values to pdf attachment in ERP

Hi everyone here am trying to edit the pdf attachment after attached to doctype. Is there anyway to do that or suggest me to do that any other way…!!!

We have instead attached images and then got them printed in PDFs via print formats. This is the easiest solution to include any external file in a print.

@dhananjay Thanks for reply.ok how to see the attached pdf in print format?

@arokia you cannot attached PDF in print format. You can use tag with “Custom Html” in the print format builder.

i want to edit pdf in attachment is there any way?

@arokia it would be better if you explain your use case there may be another way of doing what you want. However, there is no way to edit a PDF in ERPNext.
What we have do is coverted PDFs to png and included them in the print format with custom html.

What i want is am uploading a pdf into erp and on click of print button…a number to be displayed in that pdf.

I don’t think it is possible.

ok is there any way out to do this?

Have you got any solution?

@Kirubakaran_Thillaia no. did you find any solution…!

@arokia one convoluted way of doing it; use a cloud service such this pdf merge
You may be able to write a custom client script to send the downloaded PDF to the cloud service.

I have not tried it, but it seems the most plausible option.

We have converted PDFs into HTML and are appending them in custom fields. How this can be done for a limited set of PDFs.

Hi @arokia I found a solution. You can merge two pdfs using mergePage command found in PyPDF2 module.

Write a whitelisted python function to read the PDF file generated using PdfFileReader method.
Generate a seperate PDF using pdfkit.from_string method. In which you can place the values as per your need.

Using PdfFileReader.pages loop through your generated pages and merge page as per your need.

This is the function i used to generate my pdf to merger

   def get_watermark_pdf(name, itemcode):
	body = """
	      <table style='width:100%'>
	                <td style='width:50%' >{0}</td><td style='width:50%' >{1}</td>
    """.format(name, itemcode)

	filedata = pdfkit.from_string(body, False, options=options)
	return filedata
1 Like

Thanks for your response let me try and tell you.