I have a quiz built on WordPress. After a user takes the quiz the results will be mailed to the user's email address as a PDF. So the PDF is not supporting the custom fonts (II Voorkurs). We have used all options such as #fontface etc.. but still not working.
The second issue is that the content on the PDF is dynamic (text length varies as per the user test score). So this makes some elements break when there is a page break in PDF.
Cann anyone help me out?
I am using DOMPDF to create a pdf out of my html page. I need to use a specific template for the pdf to be rendered on.
is there a way with DOMPDF to use a pdf template for dynamically creating an invoice?
What is the best way to handle this? Would I need to create the template with html and css?
If it's worth mentioning, I am using Zend2 and installed DOMPDF with composer
I will recommended to use zend\pdf instead of DOMPDF. First it will bit tough but later on you can get high level performance, even able to create 100 pages at one time.
Invoice generation using Zend Pdf
For your requirement dompdf is not a bad choice but
Noway you can put your template other than using HTML and CSS
given that the functionality for exporting graphs to SVG or PNG in the Neo4j server page is broken (see SO article), are there any utilities out there that can export a graph from Neo? something that would produce a PDF perhaps?
With not many changes, you could make it work with http://www.cloudformatter.com/CSS2Pdf to format the SVGs in browser to PDF. That set of pages has some d3 samples like this: http://www.cloudformatter.com/CSS2Pdf.SVGCharts.d3Charts
I took one of the sample charts and rendered to PDF through the Javascript and the remote formatter. The page I selected was here and I took one of those charts:
http://graphgist.neo4j.com/#!/gists/1428842b2170702400451777c2bc813f
The code needs some minor change to ensure that Neo4j puts the svg namespace on the element. The samples on that page do not. But the rendering is near perfect. See the web page on the right and PDF result on the left. I only formatted the SVG and not the whole page (where the silver background exists) and that seems to be the only difference.
All recently noticed that PDF documents in Scribd are also SEO friendly for search engines. For example the link http://www.scribd.com/doc/17135767/FREE-by-Chris-Anderson
If you open the page and see the HTML source code, the plain text from the PDF is not presented. However if you open the cached version of the page from Google search it appears a tag html_wrapper which contains the text from the entire PDF document.
Do they display different content depending of User-agent that make the request - ex. browser or bots?
I've heard some SEO practices that don't recommend displaying different content for bots? How bad practice is this from SEO prospective?
this is what google sees
http://webcache.googleusercontent.com/search?q=cache:-LY7o-liYlsJ:www.scribd.com/doc/17135767/FREE-by-Chris-Anderson+site:www.scribd.com/doc/17135767/FREE-by-Chris-Anderson&hl=en&strip=1
yeah, you should not display googlebot different content then a human user, said that there are ways to do ok conditional rendering (i.e.: render for no cookie clients, render for no javascript clients, render for clients without a language header, ...) this kind of rendering can be missleading, but if is not missleading then it might be ok for google. if you do this kind of conditional rendering it's then always a question of intend.
I would like to turn the HTML generated by my CFM page into a PDF, and have the user prompted with the standard "Save As" prompt when navigating to my page.
You should use the cfdocument tag (with format="PDF") to generate the PDF by placing it around the page you are generating. You'll want to specify a filename attribute, otherwise the document will just stream right to your browser.
After you have saved the content as a PDF, use cfheader and cfcontent in combination to output the PDF as an attachment ("Save As") and add the file to the response stream. I also added deletefile="Yes" on the cfcontent tag to keep the file system clean of the files.
<cfdocument format="PDF" filename="file.pdf" overwrite="Yes">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hello World</title>
</head>
<body>
Hello World
</body>
</html>
</cfdocument>
<cfheader name="Content-Disposition" value="attachment;filename=file.pdf">
<cfcontent type="application/octet-stream" file="#expandPath('.')#\file.pdf" deletefile="Yes">
As an aside: I'm just using file.pdf for the filename in the example below, but you might want to use some random or session generated string for the filename to avoid problems resulting from race conditions.
If you want to avoid storing the PDF at all, using cfdocument without a filename will send the pdf (of flashpaper) directly to the browser without using the cfheader and cfcontent.
Caveat: Like with using cfheader/cfcontent, you need to do this before the cache gets flushed to the browser, since it's basically doing the same thing without having to store the file.
To get the content, I would probably use cfsavecontent wrapped around the same calls/includes/etc. that generate the page, with two major exceptions. cfdocument seems to have issues with external stylesheets, so using an include to put the styles directly into the document is probably a good idea. You can try using an #import instead -- it works for some people. Also, I'd be careful about relative links to images, as they can sometimes break.
The <cfdocument> approach is the sanctioned way to get it done, however it does not offer everything possible in the way of manipulating existing PDF documents. I had a project where I needed to generate coupons based using a pre-designed, print-resolution PDF template. <cfdocument> would have let me approximate the output, but only with bitmap images embedded in HTML. True, I could fake print-resolution by making a large image and scaling it in HTML, but the original was a nice, clean, vector-image file and I wanted to use that instead.
I ended up using a copy of <cfx_pdf> to get the job done. (Developer's Site, CF Tag Store) It's a CF wrapper around a Java PDF library that lets you manipulate existing PDF documents, including filling out PDF forms, setting permissions, merging files, drawing vector graphics, tables, and text, use custom fonts, etc, etc. If you are willing to work with it, you can get some pretty spectacular results.
The one drawback is that it appears the developer has left this product out to pasture for a long time. The developer site is still copyright 2003 and doesn't mention anything past ColdFusion MX 6.1. I ended up having to break some of the encrypted templates in order to fix a couple of bugs and make it work as I needed it to. Nontheless, it is a powerful tool.
I'm not that familiar with ColdFusion, but what you need to do is set the Content-Type of the page when the user requests it to be application/octet-stream. This will prompt them for a download every time.
Hope this helps!