DOMPDF page orientation both landscape and portrait - dompdf

In HTML formed sheet 3 . Each sheet is a table . We need something to convert to pdf with the last leaf was in a landscape ! With portraits it works, and how to make one of the sheets of the album .... I do not understand ...

dompdf is currently unable to do this. If you want to continue using dompdf you'll have to generate the different orientated sections separately and then combine them using an external application.
There are a number of apps for combining mutiple PDF documents. In the past I've used pdftk. It's an executable, so you would need to be able to install/run it on your system. For example:
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->load_html('...');
$dompdf->render();
file_put_contents($dompdf->output(), 'pdf1.pdf');
unset($dompdf);
$dompdf = new DOMPDF();
$dompdf->set_paper('letter', 'landscape');
$dompdf->load_html('...');
$dompdf->render();
file_put_contents($dompdf->output(), 'pdf2.pdf');
exec('pdftk A=pdf1.pdf B=pdf2.pdf cat A1 B2 output combined.pdf');
I haven't used it, but libmergepdf looks like a decent solution.
use iio\libmergepdf\Merger;
use Dompdf\Dompdf;
$m = new Merger();
$dompdf = new Dompdf();
$dompdf->load_html('...');
$dompdf->render();
$m->addRaw($dompdf->output());
unset($dompdf);
$dompdf = new DOMPDF();
$dompdf->set_paper('letter', 'landscape');
$dompdf->load_html('...');
$m->addRaw($dompdf->output());
$dompdf->render();
file_put_contents('combined.pdf', $m->merge());

Related

ArcGIS Runtime : SceneView load tif file not work

I want to load a tif file into SceneView, I tried the method from this, the code is as follows:
Esri.ArcGISRuntime.Geometry.Envelope pacificSouthwestEnvelope = ...;
// Create an ImageFrame with a local image file and the extent envelope
ImageFrame imageFrame = new ImageFrame(new System.Uri(TifFilePath), pacificSouthwestEnvelope);
//ImageFrame imageFrame = new ImageFrame(image, pacificSouthwestEnvelope);
// Add the ImageFrame to an ImageOverlay and set it to be 50% transparent
ImageOverlay imageOverlay = new ImageOverlay(imageFrame);
imageOverlay.Opacity = 1;
// Add the ImageOverlay to the scene view's ImageOverlay collection
MySceneView.ImageOverlays.Add(imageOverlay);
imageFrame.LoadAsync().Wait();
await MySceneView.SetViewpointAsync(new Viewpoint(imageFrame.Extent));
But it did not succeed.
Envelope's range is obtained in arcmap.
The LoadAsync() method is called to ensure that the layer has been loaded.
Finally, I set the display range of SceneView to the range of imageFrame.
But I did not see my picture on SceneView.
Then I tried to load .png and .jpg files, but they were also unsuccessful.
I don't know what's wrong with my code?
Finally, I used RasterLayer to complete the loading of the tif file.
Raster raster = new Raster(filePath);
RasterLayer rasterLayer = new RasterLayer(raster);
MySceneView.Scene.Basemap.BaseLayers.Add(rasterLayer);

Load issue with .tmx file

I've got an issue when I try to load a .tmx file in a CCTileMap CocosSharp object.
Here is the code :
layer2 = new CCLayer();
CCTileMap tileMap;
tileMap = new CCTileMap("TestCCS.Droid.Assets/TileMaps/TestTile2.tmx");
layer2.AddChild(tileMap);
this.AddChild(layer2);
I tried :
tileMap = new CCTileMap("TestCCS.Droid.Assets.TileMaps.TestTile2.tmx");
or :
tileMap = new CCTileMap("Assets.TileMaps.TestTile2.tmx");
The TestTile2.tmx file build Action is set to "Embedded resource"
And this my solution explorer :
Thank you for your help.
Found a way to load the TileMap file.
The solution I found :
save the TileMap file in .xml format in Tiled software.
save the .tsx file in .xml format.
I use this code to load the tile map file :
layer2 = new CCLayer();
CCTileMap tileMap;
CCTileMapInfo mi = new CCTileMapInfo("TestTile2.xml");
tileMap = new CCTileMap(mi);
layer2.AddChild(tileMap);
this.AddChild(layer2);
Where "TestTile2.xml" is an android asset.
every tile of layers must have an Id.
I had tiles without "gid", I had to set them to a transparent gid.
Hope this will help others !

tcpdf create a label pdf size width:57mm and height:32mm

guys i use TCPDF library for my php server and i want to create a label with width:57mm and height:32mm
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->AddPage('L', array(57,32));
$pdf->SetFont('dejavusans');
$html ="
<table class='domi'>
<tbody >";
for($i=0; $i<$rows; $i++){
$style=' style="font-size:'.$fontsize[0][$i].'px"';
if($bold[0][$i]===0){
$html2a[$i] = "<tr><td".$style.">".$content_line[$i]."</td></tr>";
} else {
$html2a[$i] = "<tr><td".$style."><b>".$content_line[$i]."</b></td></tr>";
}
$html2b .= $html2a[$i];//$pdf->GetStringWidth($html2a[$i])." ";
}
$html3 = "</tbody>
</table>";
$pdf->writeHTMLCell($w=55, $h=2, $x='1', $y='1', $html.$html2b.$html3, $border=1, $ln=1, $fill=0, $reseth=false, $align='C', $autopadding=true);
$pdf->Output($_SERVER['DOCUMENT_ROOT'] . 'Site/labels/label'.$id.'.pdf', 'FI');
1st of all it prints the contents fine from the database in A4 size etc but all i want is to create and save the pdf document in the label size width:57mm and height:32mm!!! https://i.stack.imgur.com/kQ8Be.png
as you see, I've marked with 1-5 numbers the actual data and the rest are marked with questionmarks!! I dont understand why of course.
2nd when i change the line $pdf->AddPage('L', array(57,32)); to $pdf->AddPage('L', array(57,57)); the label is created but i have an empty space in the bottom-right corner + it doesnt have the 32x57 size!!! https://i.stack.imgur.com/XgEWU.png
thanks in advance!!!
it seems that i had missconfigured my TCPDF library...
the simple solution that i came up was to put this line
$pdf->SetAutoPageBreak(true, 0);
after this
$pdf->SetFont('dejavusans');
and the result was perfect!!!
https://i.stack.imgur.com/hGwyR.png <-perfectly configured label
https://i.stack.imgur.com/khs9v.png <-wrongly configured label
but in my case it perfect for the job!!! all i want is to preview the result before saving (i mean saving the wrong configuration and then update the base until the configuration is good!!)

FPDF Error - Can't get image to appaear on PDF

I have a PDF with fillable forms. I can successfully fill the forms and save the new PDF to my server no problem, but I cannot place an image on the PDF. When I remove the Image(....) line the script works great. When I add it back it I get the error.
I think it's trying to look for the method in the wrong file, originally I only included fpdm..php but I tried adding back fpdf.php and it did not help. Not sure what I'm doing wrong.
Error:
Fatal error: Call to undefined method FPDM::Image() in /home/.../formPDF.php on line 113
Code:
require('../forms/pdf/fpdf.php');
require('../forms/pdf/fpdm.php');
$pdf = new FPDM($formPDFLocation);
$pdf->Image('images/sig_37-1405313221.png', 100, 20);
$pdf->Load($fields, false); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
$pdf->Merge();
$filename= "../forms/generated/" . $ffID;
$pdf->Output($filename.'.pdf','I');
FPDM is not really related to FPDF but simply a script of a FPDF user. You cannot use FPDF methods on an FPDM instance.
If you search for an all in one solution for such task you may take a look at the SetaPDF-FormFiller component (not free!).
I was able to save the PDF to my server and then add the image but lost the form contents. Code for anyone that is interested in this half solution:
Code for adding image:
<?php
require_once('fpdf.php');
require_once('fpdi.php');
$pdf = new FPDI();
$pdf->AddPage();
$pdf->setSourceFile("16.pdf");
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 10, 10, 100);
$pdf->Image('car.jpg',20,100);
$pdf->Output();
?>

How to generate pdf files in Magento

I have to generate a prduct list within a pdf file in Magento.
How can I use Zend_Pdf to do that ?
Thanks a lot.
I've found Zend_Pdf to be a little challenging to use. The way I was using it was to create a "template" pdf in some other program (i used open office calc). Saving that somewhere in the magento installation and calling
$pdf = Zend_Pdf::load('filename.pdf');
The next is to modify the pages. Mine only had one page, so I used
$page = $pdf->pages[0];
This grabs the first (and only page). To use text you have to set the font. Then draw text.
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 8);
$page->drawText($currentDate, 490, 702);
You said you would like to create a list of products, so you could do something like. It's very hackish, since you have to draw text with coordinates.
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToSelect('name');
$amountToSubtract = 0;
$beginningVerticalPosition = 480;
foreach ($products as $product)
{
$vert = $beginningVerticalPosition - $amountToSubtract;
$page->drawText($product['sku'], 40, $vert);
$page->drawText($product['name'], 150, $vert);
$amountToSubtract = $amountToSubtract + 13;
}
Then you have to render it as application/pdf instead of html. I'm not sure how you're using it so it's hard to tell what the best way would be.
wkhtmltopdf is a better option. You can take screenshots of your website with it, one way is with a new store view that only your tool uses, this can then have higher resolution images in the thumbnails, svg version of the logo and the buttons hidden.

Resources