phpexcel pdf rendering library has not been defined - pdf

After trying and failing to generate PDFs with PHPExcel 1.7.6 (out of memory errors), I upgraded to 1.7.8. I can't for the life of me figure out how to get it working. I've tried tcPDF and mPDF, and it's the same for both.
Putting it back to Excel output, I can see I'm setting the path correctly. All I can get is "PDF Rendering library has not been defined", and I can't figure out what it wants - I've tried 'mPDF5.4', 'MPDF54' (the actual name of the folder itself), 'mpdf', 'mpdf.php'...same each time.
I've been using PHPExcel for over a year, so I'm not entirely new to it. I've lost way more time than I care to admit on this problem, and I haven't found this problem described anywhere, so I'm feeling more than a little stupid that I appear to be the only one that can't figure this out.
The actual code I'm using is the following:
ini_set('include_path', ini_get('include_path').'\\Classes\\');
$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
$rendererLibrary = 'mPDF5.4';
$rendererLibraryPath = ini_get('include_path') . $rendererLibrary;
(That is, pretty well a copy of the example code.)
In the interest of completeness, the headers I'm using are
echo header("Content-Type: application/pdf");
echo header("Content-Disposition: attachment; filename=".$filename.".pdf" );
echo header('Cache-Control: max-age=0');
These near the top of the file, naturally.
Near the end of the file, the output code is
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->save('php://output');

I got it working. Much as I'd like to say I had a breakthrough moment and understand it perfectly, I have no idea how I got it to work. However, in hopes that it might help someone, let me lay out what I did.
I'm running XAMPP on Windows. My file structure has the folder for PHPExcel itself in xampp\php\PEAR\Classes. domPDF is in the same folder, and I renamed it 'dompdf'.
For reasons I no longer recall, I set the include path like so:
ini_set('include_path', ini_get('include_path').'\\Classes\\');
To set the rendering path, I used the following:
$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
$rendererLibrary = 'dompdf';
$rendererLibraryPath = ini_get('include_path') . $rendererLibrary;
For the actual writer creation, I'm using the following:
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->save($path.$fullFileName);
One thing I noticed that may have made things different was doing this:
// include 'PHPExcel/Writer/Excel2007.php';
That is, unlike everything I've done in PHPExcel, I'm not including anything from the Writer folder at all. Best I can remember, that's all that's different this time versus a week ago when I asked the question. Once I'd grabbed the 01simple-download-pdf.php file from the Tests folder in 1.7.8, it was mostly a matter of copying the code from it and tweaking it to my paths.
To summarize, leave $rendererName alone. The $rendererLibrary is the name of the folder that contains the library, 'dompdf' in my case. The $rendererLibraryPath is literally setting the path to that folder, so it ends with the path that contains the pdf library folder.
It should be obvious that I'm no uber-leet hax0r, but SO has answered many, many programming questions for me. I'm hoping this helps someone else, so they're not wasting hours like I did.

The PHPOffice contains also PHPWord. I have had the same error message with PHPWord. This is for LINUX. A replacement of 'PhpWord' by 'PhpExcel' should do the job for this case. You must modify the path $rendererLibraryPath to your needs.
$rendererName = \PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF;
$rendererLibraryPath = realpath(__DIR__ . '/../../../../../dompdf-0.6.1');
\PhpOffice\PhpWord\Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'PDF');
$objWriter->save('helloWorld.pdf');

If you are getting this error and you have set the correct path to the TCPDF or DOMPDF folder (you do not have to write the full path), then also make sure you have these lines:
if (!PHPExcel_Settings::setPdfRenderer(
$rendererName,
$rendererLibraryPath
)) {
die(
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
EOL .
'at the top of this script as appropriate for your directory structure'
);
}

Related

How to properly use QSkyBoxEntity?

I looked everywhere, but there are not any guides or explanations of how to use QSkyBoxEntity.
I created Entity and filled it with transform (set translation and 3d scale). Also changed name and extension.
When I'm trying to run program it says
"Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit for "skyboxTexture""
I checked several times and tried different png files but no luck.
My image (I know it's fake transparency, but it shouldn't change anything, right?)
And here's part of a code:
Qt3DCore::QEntity *resultEntity = new Qt3DCore::QEntity;
Qt3DExtras::QSkyboxEntity *skyboxEntity = new Qt3DExtras::QSkyboxEntity(resultEntity);
skyboxEntity->setBaseName("skybox"); //I tried using path as well
skyboxEntity->setExtension("png");
Qt3DCore::QTransform *skyTransform = new Qt3DCore::QTransform(skyboxEntity);
skyTransform->setTranslation(QVector3D(0.0f,0.0f,0.0f));
skyTransform->setScale3D(QVector3D(0.1f,0.1f,0.1f));
skyboxEntity->addComponent(skyTransform);
Looks like it's not finding the skybox texture. Did you use an absolute path when you say "I tried using path as well"? The path you set is relative to the build path, i.e. it's not where your C++ file lies.
Alternatively, you could use a resources file and then load then image using
"qrc:/[prefix]/[filename without extension]"
You can also check out the Qt3D manual SkyBox test here:
https://github.com/qt/qt3d/tree/dev/tests/manual/skybox
It's important to properly name files in order for skybox to work and use resource file for storing.
I recommend .tga, but other formats should work as well.
You can read about it here:
https://doc.qt.io/qt-6/qml-qt3d-extras-skyboxentity.html
And here's example how it should look

TYPO3: How to restrict the file upload in Powermail with the file formats

I am using powermail where I have added a file upload which I want to restrict with PNG,JPG and PDF file formats. Since I unfortunately do not work as long as TYPO3 and the extension Powermail I do not know exactly where I have to make the changes.
I have already seen in another forum post that you can make the adjustments in the setup.
plugin.tx_powermail.settings.setup.receiver.overwrite{
upload.file_extensions = jpg,png,pdf
}
Best regards
You can configure the allowed fileextension as TypoScript constant plugin.tx_powermail.misc.uploadFileExtensions.
So, the TypoScript (in constant section) should look like:
plugin.tx_powermail.misc {
uploadFileExtensions = jpg,png,pdf
}
file_extensions seems to be a configuration value years ago (The mentioned post was from 2011), but does not exist in the current powermail code.
It might be useful to know that in Powermail 9.0.2 this configuration doesn't work. This is how to acheive the same result in Powermail 9
plugin.tx_powermail.settings.setup.misc.file.extension = jpg,png,pdf

Is it possible to rename png files by the time of creation, not after

I am using File[] imageFile = PdfUtilities.convertPdf2Png(new File("MYPATH")) command to generate png from pdf , which is giving file name as "workingimage01","workingimage02"...."workingimage0n" and so on, is it possible to change this name setting by the time png's are generated. Thanks in advance.
I am trying this command for 10 pdf parallel, so it is overlapping. thats why i need to know is there a way or i am asking out of the box question.
The name is hard coded in the source. You can create an overloaded method that takes another parameter for the working files' name.

PDF to .txt using iTextSharp issues

I've finally gotten a C# project loaded as a PowerShell module, and am able to convert a PDF to text, sort of.
Some of my PDFs seem to convert fine, others get cut off at the end, and some of them just simply give me output like this:
!nn!
Q9!r
!
!!
-;7!!
H*
Q0-.(;5!!n
#n%-,-Bn
!rn-;7!H+
(-;7
,-;7
,-;79
!-;7nnn;,-
n-n
n>-rn
n!!r
n+*,
,),+I-.n
#55=
!8
(
)%
rr-;7
Q!n-;7
n!Q
!!n
F3Q02
!8nH
#*825
-n-;7
-;7nrQ
&n!!-;7C4-;7
Kn>B)I!!!I
$rn==.=!
r*.//
#5>8636nKnn
I've checked the properties of the PDF files i'm testing with, and I can't find anything that sticks out as the reason a PDF outputs gibberish like above.
Can someone please give me some ideas on what else to look for and/or change?

TextControl Images/Watermarks

In version 18 of TextControl (http://www.textcontrol.com) there is supposed to be the ability to add background images/watermarks to the document, however I find that the behavior of the various overloads, etc is not working correctly and that the documentation is rather scarce on examples. Does any one have a working example of adding watermarks to a Word document through the ServerTextControl object?
This functionality didn't exist in previous versions, so I recognize it's still rather new, I just find it weird that doing something like
tx.Images.Add(draftImage, pageNumber, location, ImageInsertionMode.BelowTheText);
doesn't actually add the images to the document, but if I use another overload beforehand, it adds both?
I just need a loop along the lines of
foreach (TXTextControl.Page page in pages){
page.Select();
var location = tx.InputPosition.Location;
var pageNumber = page.Number;
tx.Images.Add(draftImage, pageNumber, location, ImageInsertionMode.BelowTheText);
}
where location is supposed to be the beginning of the page.
Any help would be appreciated, this should be simple!
Thank you
Finally got a response to this on their forum, it's not a complete solution, but it works for the most part. Figured I would follow up here, so that anyone who ends up on this page would get the help I wanted.
http://forums.textcontrol.com/showthread.php?325522-Watermarking-Background-Image-on-Saved-Documents-in-X8&p=41815#post41815