Internal PDF link with mPDF - php

I am using mPDF library with yii framework, my PDF is generated properly but now I have to implement internal linking inside PDF. I have tried adding following HTML code but it doesn't seems to work. Has anybody implemented this. Please help
in my controller i have written following line, that is written properly in pdf
$_mPDF->WriteHTML('<div name="1b21">test internal</div>');
And somewhere in document i have written.
$_mPDF->WriteHTML('Host Name');
Thanks.

Change
$_mPDF->WriteHTML('<div name="1b21">test internal</div>');
To,
$_mPDF->WriteHTML('<a name="1b21">test internal</a>');

Related

how to get html code from pdf,docx,doc using php

I want to convert any pdf,docx,doc file into html code using php. with same style as in pdf. I am not getting proper solution.
Config::set('pdftohtml.bin', 'C:/poppler-0.37/bin/pdftohtml.exe');
// change pdfinfo bin location
Config::set('pdfinfo.bin', 'C:/poppler-0.37/bin/pdfinfo.exe');
// initiate
$pdf = new Gufy\PdfToHtml\Pdf($item);
// convert to html and return it as [Dom Object](https://github.com/paquettg/php-html-parser)
$html = $pdf->html();
Not working for me.
I had a similar problem and i found a github that i used with word docs. It worked fairly good then but i havent tested it of late. try it.
https://github.com/benbalter/Convert-Word-Documents-to-HTML
I think that this post could help you in a first time. With this one, you'll be able to convert any pdf into HTML code using PHP.
After this, you can use the help provided by this post to convert .doc and .docx to PDF using PHP.
I think that you can now built a function for each document extension that you want to convert into HTML.
Good luck.
I've come across a web service which presents an API for converting documents. I haven't tested it very thoroughly but it does seem to produce decent results at converting Word to HTML:
https://cloudconvert.org/

TCPDF Trouble - Double Coding

I'm trying to build a PDF output in CakePhp using TCPDF, I've got it working and rendering the PDF correctly etc, but something strange is happening.
It's producing a broken PDF unless I call the Output function twice.
Any ideas? or alternatives?
$this->pdf->core->Output('example_001.pdf', 'I');
$this->pdf->core->Output('example_001.pdf', 'I');
Find your solution here..
https://github.com/mozilla/pdf.js/issues/2754
may be some issue related your configuration

How to add text on pdf using PDFJam

I am using PDF Jam for manipulating pdf. I need to add a text line at the bottom of generated file. I tried it but not able to made it.
Can anybody guide me how to do it?
I did in my php code as
$command = '-----------------';
exec($command);
As you know, PDFJAM is for manipulating pds. It is a small collection of shell scripts which provide a simple interface to much of the functionality of the excellent pdf pages. See the Ubuntu Manual
pdfjam - A shell script for manipulating PDF files
You should create your sheet as your doing (5x6) and create a separate sheet of minimal page size with required information than merge both the file into one.
Else in first step create your sheet and use pdflib to add text as second step. It very good tool. I hope its a good solution of your problem.
I love pdftk and so wanted to find a solution using that. The following worked for me.
pdfjam --preamble '\usepackage{fancyhdr} \topmargin 85pt \oddsidemargin 140pt \cfoot{\thepage}' --pagecommand '\thispagestyle{plain}' --landscape --nup 2x1 --frame false --clip true --trim ".5in 0.5in 0.5in .65in" --delta '-0.25in 0' tmp.pdf
I cribbed it from: Page Numbering with the "{page} of {pages}", removing the "of pages" part.
Command converts pdf to 2x1, trims margins, and crops. Output is landscape.
\topmargin and \oddsidemargin seem to tell pdflatex where to put the numbers.

Save PDF file using PHPPdf

I'm using PHPPdf library to generate PDFs on the fly in my Symfony2 app. However I could not find a way to dump/write/save PDF raw data to a file.
From Symfony controller I tried this:
$content = $this->render('AcmeBundle:PDF:template.xml.twig');
file_put_contents('documents/123.pdf', $content);
but as it seems I get rendered HTML and not PDF binary data. When I add #Pdf annotation all output is being routed to PDF document and into browser but I need to save raw data instead for later retrieval.
I looked into FacadeBuilder but coudln't find anything useful.
Any help would be much appreciated...
Take a look at this, I think you should use $content = $facade->render($xml); like in the example action.

Webpage convert to PDF button

I have a website now and I want to create a button on it to convert this page to PDF.
Is there any code to make this happen? I cannot find it on the internet.
So I want to have a button and when I press on it it converts the page to a .PDF file.
I do not want to use a third party website to generate the PDF's. I want to use it for internal purposes to generate files with PHP. So I need the code what can make a PDF for each page.
I use wkhtmltopdf - works very well - http://code.google.com/p/wkhtmltopdf/ there is a PHP wrapper
Updated based on comments below on usage :
How to use the integration class:
require_once('wkhtmltopdf/wkhtmltopdf.php'); // Ensure this path is correct !
$html = file_get_contents("http://www.google.com");
$pdf = new WKPDF();
$pdf->set_html($html);
$pdf->render();
$pdf->output(WKPDF::$PDF_EMBEDDED,'sample.pdf');
Use FPDF. It's a well-respected PDF-generating library for PHP that is written in pure PHP (so installing it should be dead simple for you).
Try this:
http://www.macronimous.com/resources/Converting_HTML2PDF_using_PHP.asp
It will convert HTML to a PDF using FPDF and HTML2PDF class.
Also found this:
http://www.phpclasses.org/package/3168-PHP-Generate-PDF-documents-from-HTML-pages.html

Categories