Miniaturize pdf with css and html - html

I am looking to miniaturize a pdf in css and html.
when I click on my button it shows the pdf in a new tab, but I would like to see this pdf in small before clicking.
Is it possible ?

The main use of providing a miniaturized preview is to save bandwidth. So you probably wanto to provide some smaller version (e.g. a static image of the first page in .png format) of the PDF you want to preview, and will probably need some server-side scripting framework with PDF support, e.g. python-django, ruby-sinatra, php or the like.

Related

embed a pdf archive like it were part of the html code

i had a little question, i want to embed a pdf like it were part of the website, i could rewrite the pdf in html but it will be a lot of work, what would be the best looking option to embed it?
The pdf has pictures and letters with fonts and columns.
Thanks.
I would go with one of the two approaches. One is a native rendering of the PDF content in a DOM node, using PDF.js. It is an open source library that's used as the default PDF viewer in Firefox.
Another way is to emulate the look by converting the PDF pages to images when the PDF is uploaded. You may use imagemagick to parse the pages, and display the content in a slideshow/gallery widget.

HTML to PDF convertion and editing in iOS

I am creating an iPad application for reading PDF, this PDF should be generated from a HTML file. I have seen some sample codes for converting HTML to PDF, and I think that part will be fine for me to implement.
I have seen some apps from from AppStore for reading PDF files, in that there is an option for increase the font size (not zooming), color style etc. When we increase the font size the text content automatically wrapping to next line. How can I implement this in my app? Any idea about how would they have done that?
I have seen in some posts that, it is not possible to edit a PDF file, so are they actually using PDF file or some other format?
When rendering your PDF to show it to user, you can convert it in other formats like HTML and then allow user to change font-size, font-style. So your PDF remain unchanged. Also it is easy to manipulate HTML than binary formatted documents like PDF.

Can you embed an HTML webpage in a PDF file?

A flash file can be embedded in a PDF document. Does anyone know if it is also possible to embed an HTML webpage?
Added:
I don't mean just a plain HTML document, but a webpage with Javascript too.
The answer is no.
While you can embed videos, sounds and SWF files in a PDF, dynamic HTML files aren't supported. (Adobe AIR is more suitable to package and distribute HTML files).
The best you can do in a PDF is to use the ATTACH option in Adobe Acrobat. This will "attach" any file with the PDF document similar to how you add an attachment with an email. But the attachment can't be viewed within the PDF document, and has to be opened separately.
More info:
Javascript can be added to PDF files and used to manipulate various elements within the PDF file.
Not directly. Depending on what you're looking for, however, you can use something like dompdf (PHP) to generate a PDF file from an HTML document, then merge that document with your original. It even supports JavaScript, up to the level Adobe Reader supports JavaScript.
That said, the PDF file format is really for things you want to print (i.e. want to look the same everywhere), not things you want to click on (i.e. look sensible everywhere). Adobe's decision to include Flash support was probably made from a marketing standpoint, not a technical one.
The best workaround would be to create a web/html viewer in Adobe Flash and embed that in a PDF as an SWF. There is an option to "Add SWF" in Acrobat under "Rich Media."
Created a NPM module that allows you to add custom HTML and CSS to PDF's.
const pdf = require('add-html-to-pdf');
var options = {
input: 'sample.pdf',
output: 'done.pdf',
html: "<div style='color:red'>This is awesome!</div>",
useDocker: true
}
pdf.insertHTMLInPDF(options);
You could reconstruct the html, css and js on the web page using php.
Im using a plugin with a wordpress site that is pretty outdated but works very well for creating pdfs with html, css and javascript.
it's called tcpdf
plugins/tcpdf/tcpdf.php
https://tcpdf.org/examples/
the pdf is made on the fly as a function.

Getting PDF to stay in an embedded <object> or <iframe>

I've edited this quite a bit and bolded my question at this point. I realize that PDF won't be fully controllable in the browser, but that's not my issue here. My problem is, well, below in bold.
<div>
<object
data="${pageContext.request.contextPath}/UB04.xml"
type="application/vnd.adobe.xdp+xml"
width="415" height="500"/>
</div>
The XML is actually an XDP file; it gives dynamic data and a URL for a static PDF, and combines them in Adobe Reader. This displays in the browser as desired if it's a PDF, but when put in as an XDP, it takes control of the window and opens itself fullscreen to display the PDF. Serving an all-in-one XDP (with the PDF embedded as base64) has the same issue.
Help me make the XDP behave the same as a PDF?
Alternatively, if I can use iText to glue together the XDP XML and the static PDF template, I can serve the PDF directly, which seems to work just fine. Just not sure how to create PDF that route, which is somewhat underwhelmingly documented online.
This behavior is dictated by the user agent (client), and that is how it should remain. Sorry.
One possible solution: use iText to join the data into the PDF, skipping XDP entirely.
What you are looking for is called Adobe Flashpaper:
http://www.adobe.com/products/flashpaper/examples/
Otherwise you cannot dictate how the user will view the PDF.

PdfSharp, GDI+ and HTML printing

I currently have a "PrintingWebService" that I call from an AJAX page with all the information that is needed to construct a highly customized PDF printout using PDF Sharp and the PDFSharp's GDI+ mode, which takes DrawString and other commands that work basically just like GDI+ only they are drawn to the PDF.
I then save the PDF file to a location on the webserver and return the file name from the web service, and the AJAX page opens a new window with the pdf file.
So far, it works well, however, there is one part of my AJAX page that I want to printout and I haven't come up with a solution for yet. I've got a string of the HTML content of a TinyMCE editor that I want to dispay in the bottom part of the PDF page.
I'm looking for some sort of tool I could use for this purpose. Even something opensource that prints to GDI+ I could use by taking the source code and translating it to use PdfSharp's GDI+ (the class names are like XGraphics, with each class having X before the GDI+ name).
If I have to I will limit what HTML can be generated by TinyMCE and write my own renderer, but that will be a big challenge, so I'm looking for other solutions first.
I've stayed away from a printer-friendly page approach because I wanted to construct a page that was a near identical of an existing WinForms printout, using my existing code. With PdfSharp I was able to convert all the code except the text area stuff (which used the RichTextBox and RTF in the WinForms version).
Tony,
I personally have used WebSupergoo's ABCPdf library with much success. You can actually render HTML directly to the PDF and it does fairly well in regards to accuracy.
Another free software that will allow you the flexibility of writing HTML to PDF that I have used in the past with much success is iTextSharp.
Otherwise, I think you'll have to write something to render HTML to GDI.
Either way, you may want to consider using an HttpHandler that you map to using your web.config to generate the PDF file. This will allow for you to render the PDF to a bytestream and then dump it directly to the user (as opposed to having to save each PDF receipt to the web server). It will also allow for you to use the .pdf extension in the page that returns the receipt (PurchaseReceipt.pdf could be mapped to a HttpHandler)... making it more cross-browser friendly. Older versions of Adobe / Browsers will not display correctly if you start throwing a PDF byte stream from an ASPX page.
Hope this helps.