I have a dynamic pdf file which needs to be filled programmatically. I am using itext libraries to do so. Below are the steps I followed.
Extract the dynamic pdf and get the data xml file.
Fill the xml data file.
Call the itext apis to generate new pdf by passing the template pdf and xml data file.
The issue I face is if there is a repeater inside the container (which has a close button) in the template pdf, its not copied into the generated interactive pdf file. None of the javascript functionalities are triggered when creating the new pdf and because of which some of the fields become read only.
Is it possible to trigger the javascript in the pdf while generating the new pdf or while opening the new pdf?
Much appreciate any help.
Related
I want to allow my users to save my page as a PDF. I have created a print stylesheet and I can generate the PDF by using Javascript's print function. Here's my problem:
In Chrome, the browser generates a preview and shows it to the user. The user can then either save it or print it.
However, in IE and FF, print calls up a complex menu, and while it can generate a PDF by "printing" to PDFCreator, it's a complex process that many users won't understand.
What I want to do is to somehow duplicate the Chrome functionality for non-Chrome users. Options I have considered:
Screenshot the HTML page and render that image into a PDF with Javascript. There are libraries that do this, but I want my PDF to have the print layout.
Generate the PDF on the server and send it to the user's browser. This can be done, but it seems difficult to use the same HTML as the standard page.
My server is running PHP and the Zend framework. I can't use NodeJS or any headless browser to render on the server. Do I have any options?
I've done exactly what you want to do before using a library called dompdf (https://github.com/dompdf/dompdf). Here is how I used it:
I dropped the dompdf library into the "library" folder in my ZF project. Then, in my application when I'm ready to render the page I created a new Zend_View() object and set it up with whatever view script variables it needed. Then I called the render() function and stored the rendered output into a variable I then provided to dompdf. The code looks like this:
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/views/scripts/action_name/');
$html->assign($data); //$data contains the view variables I wanted to populate.
$bodyText = $html->render('pdf_template.phtml');
require_once(APPLICATION_PATH."/../library/dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($bodyText);
// Now you can save the rendered pdf to a file or stream to the browser:
$dompdf->stream("sample.pdf");
// Save to file:
$dompdf->render();
$pdf = $dompdf->output();
file_put_contents($filename, $pdf);
I have a decodification problem.
I have an offline desktop application, where I have to generate a pdf file and save at his open.
To generate the PDF file I use BytescoutPDF library createpdf.js.
This returns a document variable that I have to save.
I tried with:
//this calls the createPDF to BytescoutPDF library
//and returns the variable into 'doc'
var doc = generaStaticPartBolla_2();
//take the stream
var bolla = Ti.Filesystem.getFileStream(billPath);
//open in write mode
bolla.open(Ti.Filesystem.MODE_WRITE);
//write the doc file decodified in Base 64
bolla.write(doc.getBase64Text());
//close the stream
bolla.close();
Now, the file generated is currupted.
I'm not able to open this. How can I do this? The file must be converted in Base 64 or other?
I don't know if you have solved your issue now, but I had the same requirements : offline app, generating pdf from HTML, and in my case, styling the generated pdf with CSS.
After trying many solutions, the main problem was to style with CSS.
Finally I used WkhtmlToPdf (http://wkhtmltopdf.org/). Basically I embed the binaries (for mac os and for windows) in the app, and regarding the platform, I execute them with the Ti.Process method.
WkhtmlToPdf generates a pdf in the specified path, so in this way, you will be able to open this pdf.
(In order to set the path for the pdf, i use openSaveAsDialog (http://tidesdk.multipart.net/docs/user-dev/generated/#!/api/Ti.UI.UserWindow-method-openFileChooserDialog) which allows the user to set the path and the name of the generated pdf).
I would like to use jQuery to POST for a dynamically generated PDF and display it on the same page.
I have successfully been able to POST the data to a PDF generating script (PHP), create a randomly named PDF file, and return that for jQuery to put into an <object></object> however that generates two requests. I also don't want to have jquery set an <object> src to generate.php?data=DATA_HERE due to the fact that there is a lot of data and I would rather POST
I would like to fetch the binary PDF data with jQuery and embed it into the DOM. Is this possible?
I'd like a snipe of code to convert a google docs text document template in a PDF file. I know how to create a new document as a google text document, but not how to transform it in a PDF file.
I find this piece of code:
var pdf = UrlFetchApp.fetch("https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key="+key+"&exportFormat=pdf&gid=1&gridlines=0&printtitle=0&size=7&fzr=true&portrait=1&fitw=1", requestData).getBlob().setName(name);
return pdf;
But I don't need spreadsheet customization (actually, I don't need spreadsheet, but text file).
How can I can do it? Only with UrlFetchApp.fetch class?
One more question: can I automaticaly send this PDF file to be printed after I've created it?
Thanks!
If I understand you correctly your question is about getting a text document as pdf ?
There is a dedicated method for that :
DocsList.getFileById('document ID').getAs('application/pdf');
see related documentation here
I have an XML file which is rendered by a set XSL file (XSLT 1.0). The XSL file includes several other XSL files with multiple templates in them.
What I need to do is include a button in the rendered XML to open the same XML in a new window, using some different templates in the XSLs.
Including the button and opening a new window is not the problem, but how do I tell the XSL to use different templates because it got opened in a new window? My idea was to use JavaScript for opening the new window, but I don't see how I could set or pass a parameter to check on with XSLT/XPATH.
Thanks in advance for your help!
Change the xml or transform server side (with php,asp,jsp...) or client side (with javascript). You can parameterize only the xsl processor, but not the xml file. If you don't want to use xsl processor, then you have to recreate the xml file on server side with same body and different header with another stylesheet.
I did it by using querystrings.
Upon loading opening my URL in a new window
window.open(window.location+'?a=1')
in the JS onload event I check if the querystring is empty
if(window.location.search=='')
if not I search for the links by class and remove the attributes
.removeAttribute('href');
.removeAttribute('onclick');
To clarify, the templates would simply have removed some links from the page. It was easier to simply remove them by JS than using different templates.