mPDF invoice print multiple invoices in one page - php

So. I'm using mpdf 6.0 and my plan is to generate an invoice por every sale that is half page original for the client and the other half page as a copy for me.
But I can't seem to get the page division right. So I thought about using a custom page size. A5 in landscape mode. But when I need to print them they each take a full page. Is there any way to force 2 pdf pages per physical page. Or do I have to just treat the whole thing as one A4 page and just draw both invoices in the same page?
I'll try to improve the wording as soon as possible but right now I'm in a hurry.

Related

Issue in loading time and size of images for PDF first page preview

I am working on website which is having huge amount of PDFs shown to its page. Those PDFs are listed on the page. The count may be 150 on every page.
We need to show the preview of first page of those PDFs to show the user whats inside every PDF.
What I am doing now?
While uploading those PDFs on clouds, I am creating previews of first page of those PDFs (1 small preview and 1 large preview) using a tool called PQScan.
Small preview will be shown on page by default, Large preview will be shown on mouse hover.
What is the problem?
For around 150 PDFs per page, The loading time of small and large preview(.gif/.jpeg/.png images) from cloud is taking a lot of time.
Image for refrerece on how I am showing -
Is there any better way to tackle this problem to resolve the issue faced? Also the size occupied by these images on cloud?
Some suggestions from my knowledge are:
Use Lazy loading technique to improve your page load time. Refer Google Documentation to know more about this.
Save random pages of the document as single images (such as cover page, some 2-3 random pages in between). Then instead of automatic slideshow or GIF, only show the cover page preview image. And on mouse hover, you can load and display other pages as slideshow or any animation effect you can implement.
Use Next Generation image formats as they are much smaller compared to older formats. Refer here for more detailed information.

Page number print on header when total page greater than one in TCPDF

I have one specific problem in PDF.
My requirement is that i have to print page number in header of the page only when total page of pdf is greater than 1.
I think this is not possible because before completing whole pdf page we can get total page number.
I think you have any idea to apply my condition in TCPDF.
I have tried all function related page number nothing working.
Thanks In Advance.

Is any progress bar feature implemented with TCPDF API

From last 6 hours trying best to show progress bar wile pdf is generated in TCPDF but not successful.
I am using TCPDF API for HTML to PDF generation, But the problem is that while generating the PDF we can't use custom javascript, Can we show progress bar while PDF is generated?
Any idea please?
I am not sure why you say "can't use custom javascript". If you just want a "loading icon" yoy should do this
- show loading icon (from js)
- ajax request to php file that generates the pdf into a server file
- on success you get a link to a generated pdf.
(for this solution you might try some estimation based on how large would be the generated file)
If you want an accurate progressive, you should add some estimation on php file. Let's say when you generate the pdf you know how many pages you will generate and each "addPage" command you save the status of completeness in a file or a memcached key. On you JavaScript side you call a file each second that reads that status of completeness.
No.
Even if you were able to use custom javascript, it would not be possible to get an accurate prediction of the time it will take to generate the document and therefore diplay progress - but it would be possible to get an estimate (based on extensive benchmarking). But in order to display the progress bar you'd need custom javascript and to change the processing to decouple the threads on the browser and server. This is discussed more in this question (which IMHO is not a duplicate of the post referenced).

Device orientation & pagination

I'm currently working on a mobile site that has tiles which represent each article. The pages have 15 tiles on them which is clean and works for both orientations on a mobile device. I recently added a featured article which takes up two space tiles worth of page space, so now I have one tile that is widowed on the bottom of the page.
Using some media queries I'm able to show/hide the last two tiles which works great until users click to the next page of tiles. If a user is in portrait orientation then they will miss two article tiles because they were hidden on the last page.
So I want to create some type of AJAX function that allows me to check the orientations and dynamically change the tile count request server side. Is this possible?
Jquery Mobile offers methods to look and know the orientation of the device.

Automated image update with page statistics

Frankly I am not sure where this would go but I assume the way to create what I'm about to describe is PHP... so I'm sorry if it's in the wrong section.
Basically I have a website, using Wordpress, where users can review websites and post a 5 star rating of the site. Each reviewed website has it's own dedicated page.
So what I want to do is create an image from the statistics of the ratings to allow the website owners to place it on their page. The image will need to, when clicked, go to that it's review page.
So the image would be about 150x150. Have the overall 5 Star Rating, the Name of the Reviewed site and the name of my website. It would also be cool if there was some automatically generated HTML embedding code so the site owners can simply copy and paste it.
I hope I explained myself ok. I've tried searching google but I'm not entirely sure what to search for and therefore have found nothing useful.
Thanks.
EDIT
I can create the embed code manually. I just need to really know about how to make the picture update automatically.
Hey what you are asking for is quite complex and it would be to easy to just give you code. So here is some reading for you. Your problem is quite meaty and no doubt you'll learn loads sorting it out....
http://www.phptutorial.info/learn/create_images/
http://www.qualitycodes.com/tutorial.php?articleid=20&title=How-to-create-bar-graph-in-PHP-with-dynamic-scaling
I just need to really know about how
to make the picture update
automatically.
Just put URL to your php-script, which will generate image.
You will need function imagettftext to write text over the image, imagecopy to draw the stars (of votes).
Also, you will need image of a star and background.
So, approx. algorithm will be:
1. Open the background image by imagecreatefrompng - it will be our generated image
2. Open the Star image
3. Write title of the reviewed site by imagetttftext
4. Draw stars by copying existing Star image to our background image (by imagecopy)
5. Print generated image by imagepng

Categories