Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TCPDF - Width Longer than Height
10-19-2016, 07:46 AM,
#1
TCPDF - Width Longer than Height
Hi All,

I'm trying to create a PDF document where the width is larger than the height without having to set the orientation to landscape. The document needs to be printed through an impact printer where the sheets are all attached together and printed in from a portrait perspective.
Any suggestions on how I can accomplish this?

Best Regards,
Felix
Reply
10-19-2016, 10:07 PM,
#2
RE: TCPDF - Width Longer than Height
Felix
What document are you trying to print invoice, order?
In the main setup you can change the Invoice Orientation:
More info would be helpful.
Thanks
Dave
Reply
10-19-2016, 10:41 PM,
#3
RE: TCPDF - Width Longer than Height
I'm not an expert with TCPDF but I know from experience using it with custom page sizes can be a painful experience. I don't know whether Rafael monitors this forum but he has more knowledge of TCPDF.

Tim
Reply
10-20-2016, 01:56 AM,
#4
RE: TCPDF - Width Longer than Height
Hey Dave,

I created my own pdf document for printing AP checks based on the print invoice.

I'm printing on continuous paper that has shorter length than letter sized and A4. I am unable to create a custom page size where the width of the document is longer than the length. It seems like TCPDF uses whichever dimension entered that is longer as the length. It would be fine if I can print the check in a landscape orientation, but the paper can only be fed in the printer one way. I made the length and width the same size for now as a compromise.

When I view the PDF that generates the document size is the one I set it to, but when it prints out the gap between the first page and the second page is the difference between a regular letter size paper length and the length of my document. In my printer options I set the page size to my custom page dimensions, but it still doesn't align. I'm not sure if it's my printer driver or there's something in the code I still need to change.

Attached is a copy of the PDF if you want to take a look.

Hey Tim,

Thanks, if I can't figure it out today, I'll email Rafael to see if he has insight.

Regards,
Felix


Attached Files
.pdf   APCheck.pdf (Size: 8.28 KB / Downloads: 7)
Reply
10-20-2016, 02:20 AM, (This post was last modified: 10-20-2016, 02:23 AM by daveparrish.)
#5
RE: TCPDF - Width Longer than Height
Felix
I you look at your .php file in the first few lines you will see

if (isset($_POST['PrintPDF'])) {
$PaperSize='A4_Landscape';

This refers to the PDFstarter.php located in the inc folder you will find

case 'A4_Landscape':

$DocumentPaper = 'A4';
$DocumentOrientation ='L';

$Page_Width=842;
$Page_Height=595;
$Top_Margin=30;
$Bottom_Margin=30;
$Left_Margin=40;
$Right_Margin=30;
break;
This sets the page height and margin what I did was add the code

case 'A4':
$DocumentPaper = 'A4_Custom';
$DocumentOrientation ='P';

// Javier: DIN-A4 is 210 mm width, i.e., 595'2756 points (inches * 72 ppi)
$Page_Width=595;
$Page_Height=800;
$Top_Margin=30;
$Bottom_Margin=30;
$Left_Margin=40;
$Right_Margin=30;
break;
Then in my .php file I changed the code to
if (isset($_POST['PrintPDF'])) {
$PaperSize='A4_Custom';

Hope this helps

Sorry should have been
case ''A4_Custom'':
$DocumentPaper = 'A4';
$DocumentOrientation ='P';

// Javier: DIN-A4 is 210 mm width, i.e., 595'2756 points (inches * 72 ppi)
$Page_Width=595;
$Page_Height=800;
$Top_Margin=30;
$Bottom_Margin=30;
$Left_Margin=40;
$Right_Margin=30;
break;
Then in my .php file I changed the code to
if (isset($_POST['PrintPDF'])) {
$PaperSize='A4_Custom';
Reply
10-20-2016, 04:18 AM,
#6
RE: TCPDF - Width Longer than Height
Hey Dave,

Thanks, but still no luck. I think the page dimensions are set correctly in the PDF, but when it prints the spacing between pages is still off.

Regards,
Felix
Reply
10-20-2016, 05:12 AM,
#7
RE: TCPDF - Width Longer than Height
Just a thought ... the pdf may be correct but the printing of a pdf with a page size that does not match the paper size in a printer can be the cause of trouble too.
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
10-20-2016, 05:33 AM,
#8
RE: TCPDF - Width Longer than Height
I agree with Phil I found some NCR forms and they match the size of your document I would guess that it is to do with printing the pdf to a dot matrix printer you may need to adjust the size in TCPDF to get it to work. You may want to also look at Batch Print Pro this has a lot of different function for converting and auto printing documents we have been using it for about a year without an issue.
Thanks
Dave
Reply
10-20-2016, 08:42 AM,
#9
RE: TCPDF - Width Longer than Height
Thanks for the help everyone. I finally got it to work by using a windows 7 computer and adding a custom form size to the print server that matched my document size. It didn't work when I tried to do it on my linux machine.
Regards,
Felix
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)