-1

I am building a Web2Print website using PHP, MySQL and jQuery.The main concept of the website is the end users can create a HTML template by adding text, images, dragging, resizing etc dynamically and convert it to high-res A4 size PDF and then moves to printing.

For example see the link http://optisolbusiness.com/funeral_site/sample/index/id/255. This is the sample HTML that is to be converted to PDF. The width and height of the webpage HTML is 356x405px the problem is when I convert it to A4 PDFs size 8.5X11.69inches the HTML shows very small in PDF.

So I have to increase the width and height of the HTML to fit the PDF size, while increasing the HTML size to 8.5X11.69in. The content inside the HTML should also increase proportionally (ie) the text font size, background image, images width and height, top left should also be increased proportionally. The PDF should fit exactly like the HTML. I am using the online API htmlpdf.com to convert to PDF.

halfer
  • 19,824
  • 17
  • 99
  • 186
PHPDev
  • 139
  • 1
  • 3
  • 12
  • What internal format are you using to store your documents? SVG, maybe? Or are you painting text and images on a PDF directly using TCPDF or similar? – halfer Oct 11 '12 at 07:52
  • Which one would be better to achieve this? – PHPDev Oct 11 '12 at 07:54
  • More detail first. You mention 'when I convert it to A4 PDF' - what software are you using to do that? (Edit it into your question please). – halfer Oct 11 '12 at 07:57
  • I am using online API http://www.htmlpdf.com/ to convert to PDF – PHPDev Oct 11 '12 at 07:58
  • Hmm, how does that service know that your input is to be scaled up to A4 in size? Does it read CSS3 @page stuff? Also bear in mind bitmap text [like this](http://optisolbusiness.com/funeral_site/images/template1/01_basic_frontcover.jpg) will render very badly when printed - it needs to be a vector graphic or a proper font. – halfer Oct 11 '12 at 08:03
  • Is there some other ways to achieve this? – PHPDev Oct 11 '12 at 08:10
  • OP, in case you've not seen it, I've answered below; you can still comment on existing answers in a closed question. – halfer Oct 11 '12 at 14:06

1 Answers1

0

How to do this? There are several approaches, but you must be willing to do your own research. You can paint PDFs in a variety of ways:

  • using graphics primitives in PHP libraries such as FPDF and TCPDF
  • using reporting software with document templates, such as JasperReports (requires server root access)
  • by converting from HTML, say via wkhtmltopdf (free) or Prince (expensive)
  • by manipulating SVG and rendering it to PDF, say in Inkscape (I've not seen other people taking this approach, but I have a working demo - see here. Only recommended if you are comfortable manipulating XML programmatically)

Remember that to get hi-res output (300-600pdi) on paper, you need to use proper fonts or vector graphics. These render at the resolution required, and won't pixellate if you use them properly. Failing this, use bitmaps at the correct resolution, so if you have a 1200px square image, and you wish to print at 600pdi, then the image cannot be larger than 2 inches either side.

In general it is best not to rely on third-party conversion services unless you have a contract with them - since they can take their site down or deny access at any time, and your work would be wasted.

Community
  • 1
  • 1
halfer
  • 19,824
  • 17
  • 99
  • 186