Posts

Showing posts with the label Pdf Generation

Android PdfDocument File Size

Answer : There are a few main things that increases the size of a PDF file: hi-resolution pictures (where lo-res would suffice) embedded fonts (where content would still be readable "good enough" without them) PDF content not required any more for the current version/view (older version of certain objects) embedded ICC profiles embedded third-party files (using the PDF as a container) embedded job tickets (for printing) embedded Javascript and a few more Try using iText. Following links give a basice idea for iText in android. http://technotransit.wordpress.com/2011/06/17/using-itext-in-android/ http://www.mysamplecode.com/2013/05/android-itext-pdf-bluetooth-printer.html https://stackoverflow.com/a/21025162/3110609 In case anyone is still looking for a solution... I was working on a project to generate PDF from images and not satisfied with the file size generated by both Android's PdfDocument and 3rd party AndroidPdfWriter APW. After some trials I ended...

Converting HTML To PDF Using IText

Image
Answer : Why your code doesn't work As explained in the introduction of the HTML to PDF tutorial, HTMLWorker has been deprecated many years ago. It wasn't intended to convert complete HTML pages. It doesn't know that an HTML page has a <head> and a <body> section; it just parses all the content. It was meant to parse small HTML snippets, and you could define styles using the StyleSheet class; real CSS wasn't supported. Then came XML Worker. XML Worker was meant as a generic framework to parse XML. As a proof of concept, we decided to write some XHTML to PDF functionality, but we didn't support all of the HTML tags. For instance: forms weren't supported at all, and it was very hard to support CSS that is used to position content. Forms in HTML are very different from forms in PDF. There was also a mismatch between the iText architecture and the architecture of HTML + CSS. Gradually, we extended XML Worker, mostly based on requests from customer...

Add Image In Header Using Html-pdf Node Module

Image
Answer : It is possible to add the image in options header. 1.Load the image in html body with "display:none" style. 2.Then add the image in the options header By doing this the image is cached and can attach the image in header. var options = { "format": 'Letter', "orientation": "portrait", "header": { "contents": "<img src='image path' />", "height": "30mm" }, "footer": { "contents": footer } } pdf.create("<div style='display:none'><img src='image path' /></div>", options).toFile("sample.pdf", function(err, res) { if (err) { console.error(err); callback(); } }); Refering to this issue on the github, you can't put your image directly in options.header , you have to put it in the body inside a <div id=...

Convert Word Doc, Docx And Excel Xls, Xlsx To PDF With PHP

Answer : I found a solution to my issue and after a request, will post it here to help others. Apologies if I missed any details, it's been a while since I worked on this solution. The first thing that is required is to install Openoffice.org on the server. I requested my hosting provider to install the open office RPM on my VPS. This can be done through WHM directly. Now that the server has the capability to handle MS Office files you are able to convert the files by executing command line instructions via PHP. To handle this, I found PyODConverter : https://github.com/mirkonasato/pyodconverter I created a directory on the server and placed the PyODConverter python file within it. I also created a plain text file above the web root (I named it "adocpdf"), with the following command line instructions in it: directory=$1 filename=$2 extension=$3 SERVICE='soffice' if [ "`ps ax|grep -v grep|grep -c $SERVICE`" -lt 1 ]; then unset DISPLAY /usr/bin/soffice...