How to add header in an uploaded PDF using barryvdh/dompdf - php

I am using barryvdh/dompdf in my project to deal with pdfs. Yes as you are thinking with php and Laravel.
In backend, I have a form which uploads a pdf and from the frontend we can download it.
This functionality is working perfectly.
But now I want to add a header in that uploaded pdf to add my project's name.
I have worked with pdf generation by this package so I know how this package works but I can't find anything about editing a pdf.
I have been doing some research on google but can't find anything related to my problem.
I haven't done anything so far related to this so I have no more details or code to show but to clear confusion let me just show you the points you need to keep in mind and forget anything you read till now.
I am using barryvdh/dompdf to deal with pdfs.
Want to edit a pdf which is uploaded in the system and will be downloaded afterwards.
I Want to add a header.
I just have a mere idea(maybe i am wrong) that it can be done at any of the two stages-
1. At upload time
2. At download time
[Note]: Please don't close it as off-topic or duplicate or something similair. Please do read the whole post before doing anything like that. Because like I said, I have done some research and haven't found anything.

This can't be done in DOMPDF.
I guess the solution is to either use native-ish php commands, another package like FPDI or to drop the idea altogether.

Related

Recover the overwritten file from google cache

I have overwritten my file( a webdocument with extention .php) with the old one, I tried to access the cached version from google and I found the one i.e,http://webcache.googleusercontent.com/search?q=cache:http://minnesotataxiandcarservice.com/testimonials.php&strip=0 but I am looking for a way to recover it, when I tried to view its source code all I can see is the html scrips only as the php part is not visible. Now I am looking for a way to retrive a whole document with original contents including the php coding. If there is any way to do so please mention it.
You can't.
Next time, you should be using a version control system, like Git

PHP un-editable pdf/file export option

I am developing an application in the Kohana PHP framework that assesses performance. The end result of the process is a webpage listing the overall scoring and a color coded list of divs and results.
The original idea was to have the option to save this as a non-editable PDF file and email the user. After further research I have found this to be non as straight forward as I hoped.
The best solution seemed to be installing the unix application wkhtmltopdf but as the destination is shared hosting I am unable to install this on the server.
My question is, what's the best option to save a non editable review of the assessment to the user?
Thank you for help with this.
I guess the only way to generate a snapshot, or review how you call it, is by storing it on the server side and only grant access via a read only protocol. So basically by offering it as a 'web page'.
Still everyone can save and modify the markup. But that is the case for every file you generate, regardless of the type of file. Ok, maybe except DRM infected files. But you don't want to do that, trust me.
Oh, and you could also print the files. Printouts are pretty hard to be edited. Though even that is not impossible...
I found a PHP version that is pre-built as a Kohana Module - github.com/ryross/pdfview

FPDF Error: Error while decompressing stream

I've built a web application incorporating the fpdf library which allows clients to upload pdf files which my system then combines into a monthly report (adding a cover, contents page etc.).
Last month I got this error:
FPDF Error: Error while decompressing stream
I've googled it and the only people who have encountered it before seem to be German!
The error handler is at line 241 of fpdi_pdf_parser.php and refers to "case '/FlateDecode':" and other things I don't understand.
I traced the problem to a single pdf file which appeared normal but consistently caused the problem. I created a new version of the pdf by screen grabbing from the old one and when I uploaded that everything worked.
As I say I got round the problem but don't really understand how and don't want to run into the same thing again.
Any ideas what was going on?
Thanks in advance.
PDF files can be compressed in different ways with different algorithms, if your application is open to receive any file it is possible that you got a corrupt one that FPDF was not able to decompress. Even in such scenarios (I mean corrupt files) other PDF parsers/readers may be able to recover the file and show the content (or some part of it), but it does not mean the file is valid.
It is also possible that this file contains some specific feature from the PDF specification that is not supported by FPDF. If it is an option for you to post the offending file it might be possible to narrow down the issue a bit more.
usual in such cases helps install or update zlib module by PHP. The problem also arises due to the pictures are inserted into the pdf-document (see requirements by image on http://www.fpdf.org/en/doc/image.htm).

generate images from swf

Is there any library/module available with which i can generate images from a swf file?
The problem i am trying to solve is: I want to create a pdf from a web page and i am having problems in doing that when the web page has swf (question in stackoverflow)
I am thinking if i am able to read a swf and write out an image, i will be able to solve the above the problem
Will appreciate your help, Thanks
In fact, that is quite a hard task. I've spent hours looking for a program that could fulfill such a task. However, I eventually only found one. It isn't open-source but would really help you I guess.
Flash Animation Source can output all frames of a SWF file. It uses a DirectShow filter to do so. Therefore, a Windows operating system is required should you not want to use WINE.
In short, you'll just need to install Flash Animation Source on your computer and then find a way to get DirectShow frames using your desired programming language. Everything else is actually quite easy. You tell Windows the directory and the name of your SWF file and it'll do the rest, thus delivering you with an image. And did you know DirectShow filters can deliver all frames of a video? Therefore, you can choose which one you'd like to have.
By the way, please don't try to find another way to get an image of your SWF file. Believe me, you won't find one. I have looked for an open-source program that fits my needs but all of them fail. You need to use the propriertary Adobe Flash player for your outputs. There is no other option as the open-source alternatives still need a lot of development to genuinely output the vector-based frame as it is.

Check if a PDF file is corrupted with PHP

I was wondering if is there a way for php to check if a PDF file stored locally on the server is corrupted or not. We have a php application that deals with a lot of scanned documents converted in PDF and it would be nice to check which of them is corrupted to alert the user.
I tried to look around but with no luck.
There are versions of pdflib available which can read PDFs - you could simply try to open and read each page with that.
The problem is there are many ways a PDF file can be corrupt.
Maybe your best solution would be to find a PDF reading lib and try to extract the first word from each page or something. That would at least catch some basic types of corruption.

Categories