Sie sind auf Seite 1von 2

7/17/2020 php - Is there any way to make a pdf which cannot be converted to word?

- Stack Overflow

Is there any way to make a pdf which cannot be converted to word?


Asked 4 years, 4 months ago Active 4 years, 4 months ago Viewed 2k times

We have a system which is generating PDF files. But anyone can convert those files using online
pdf to word converter. Is there any option available in Yii or PHP to stop this?
0
php pdf yii ms-word

edited Mar 7 '16 at 15:17 asked Mar 7 '16 at 6:42


1 Deduplicator tharinducs7
39.8k 6 57 99 81 2 14

have you tried to encode the file/text into image and then generate pdf using that generated image. This
make the pdf can't be copied therefore can't be converted to word document – Ferico Samuel Mar 7 '16 at
6:48

Nothing that can't be circumvented – user557846 Mar 7 '16 at 6:49

I fail to see the point of why would someone want to do that. Seems to be an user limiting feature that
achieves nothing (like disabling the right click on webpage). If you are afraid of forging documents under
your name you should get certificate instead and digitally sign your pdfs. – user4029967 Mar 7 '16 at 16:24

@vove : that's not my requirement. Client's requirement – tharinducs7 Mar 8 '16 at 4:27

@TNC it obviously is impossible to prevent people from converting a Pdf to a word file, they can always
take screenshots and add them to the word file as images, probably with some OCR applied. Thus, you
should clarify with your client what exactly he wants too express with that requirement. – mkl Mar 9 '16 at
6:01

3 Answers Active Oldest Votes

To prevent PDF from been converted into Word you may:

1. Set password that is required to view PDF - once password is shared - it can be removed
1
2. Convert PDF to images, then convert these images to PDF (using ImageMagick,
Ghostscript) - recoverable using OCR.
3. Write your code that damages so-called CMAP ( /ToUnicode dictionary) inside generated PDF
so the copied text will not match the text that is displayed to viewer - but still recoverable
using OCR.
4. Use the handwritten font for text that is drawn into image. Then these images are saved as
JPEG and these JPEG files are converted into final PDF - not recoverable using OCR but
can be recovered using HWR
5. Use vector drawing commands to draw your own letters line by line, so will look like letters
but will not be recognized by PDF readers as text - still recoverable using human eye.
6. Finally, you may skip generating PDFs but instead print a physical document, make a hard
cover for it and send by a physical post to your customers and suppose they are lazy enough
https://stackoverflow.com/questions/35837674/is-there-any-way-to-make-a-pdf-which-cannot-be-converted-to-word 1/3
7/17/2020 php - Is there any way to make a pdf which cannot be converted to word? - Stack Overflow

not to remove the cover and scan you document page by page with OCR software.

edited May 23 '17 at 10:28 answered Mar 9 '16 at 21:00


Community ♦ Eugene
1 1 2,497 16 18

To disable converting PDF in any other format you can use for example PDFTK command line,
you can find it here
0 It will prompt a password when user try to print your PDF document (consider converting format is
also a printing mechanism)

command line

pdftk source.pdf output destination.pdf user_pw password

So to use it in PHP do not forget to add PDFTK to your PATH environment variable, set access
authorizations and restart your web server

EDIT you can use shell_exec()

<?php
// ...
shell_exec('pdftk source.pdf output destination.pdf user_pw password');
?>

edited Mar 7 '16 at 7:59 answered Mar 7 '16 at 6:55


Halayem Anis
6,942 2 16 37

2 If the password specified is the "user" password (in PDF context), it means that this password has to be
provided when the document is opened. The password to restrict capabilities is the "owner" password.
Among those restrictions is printing and page extraction. Converting to Word is page extraction. The
problem with those passwords is that a non-well-behaving application can simply ignore them. So, the
question is whether this simple command line command will provide sufficient protection. – Max Wyss Mar
7 '16 at 10:49

Any text in a PDF can be converted to any other textual format.

You may try rendering the information you want to put into PDF as an image, then insert the
0 image into the PDF.

This way, when the PDF is read, the image data is gotten. Although this may still be converted
into any format if the converter is persistent, it makes them do more work.

answered Mar 8 '16 at 14:34


iGbanam
5,285 4 36 61

https://stackoverflow.com/questions/35837674/is-there-any-way-to-make-a-pdf-which-cannot-be-converted-to-word 2/3

Das könnte Ihnen auch gefallen