Comments (8)
Problem solved.
Instead of
...
def _escape(self, s):
#Add \ before \, ( and )
return s.replace('\\','\\\\').replace(')','\\)').replace('(','\\(')
...
use
...
def _escape(self, s):
# Add \ before \, ( and )
return s.replace('\\', '\\\\').replace(')', '\\)').replace('(', '\\(').replace('\r', '\\r')
...
You may also compare to function _escape() in tfpdf
(http://fpdf.org/en/script/script92.php).
Would you be so kind to check this issue? Possibly this modification could be
taken into the sources.
Original comment by [email protected]
on 22 Jan 2013 at 1:45
- Added labels: ****
- Removed labels: ****
from pyfpdf.
Are you sure that \x0d\x0a pair in source text lead to this issue?
Is anybody know some PDF reader for linux to test this issue? (except Adobe
Reader)
Original comment by [email protected]
on 22 Jan 2013 at 2:00
- Added labels: ****
- Removed labels: ****
from pyfpdf.
1. Are you sure that \x0d\x0a pair in source text lead to this issue?
yes, really sure. You may create a pdf with only these symbols
"""
U+010A -- Ċ -- Latin Capital Letter C with dot above
U+010D -- č -- Latin Small Letter C with caron
U+010E -- Ď -- Latin Capital Letter D with caron
""".
Do it once with pyfpdf and once with tfpdf (under php). Compare the resultant
pdf docs with a hex-diff-tool (i took gvim on windows). I recommend to set
compression off.
Then you may compare the sources of tfpdf's function _escape() to pyfpdf's def
_escape().
Additionally you may search fpdf.py for "txt2 = self._escape(UTF8ToUTF16BE(txt,
False))" and log the text before and after UTF8ToUTF16BE and after
self._escape. You may do this once in pyfpdf and once in tfpdf.
I checked the new pdf (with \\r instead of \r)
on Windows with
- Adobe Acrobat Reader XI,
- FoxIt Reader 5.4,
- Google Chrome,
on Linux with
- evince,
- gimp import,
- xpdf
on HP-UX with
- Adobe Acrobat Reader 5.0,
and on Android with
- Polaris office
All readers show symbol U+010D as expected.
2. Is anybody know some PDF reader for linux to test this issue? (except
Adobe Reader)
I took xpdf and evince.
Original comment by [email protected]
on 22 Jan 2013 at 3:25
- Added labels: ****
- Removed labels: ****
from pyfpdf.
Edwin, still not sure if escaping is right way.
But references (both 1.3 and 1.7) didn't specify how to properly integrate
unicode string literal into text object (ie mix 7-bit string with UTF16BE).
Ref specify only BOM mark for all text string, not for one text literal.
Ref 1.3 also complain about encrypted 8-bit literals, but who care.
Please test this patch. (small refactor and proposed change)
1. http://www.adobe.com/devnet/pdf/pdf_reference_archive.html
Original comment by [email protected]
on 23 Jan 2013 at 7:22
- Added labels: ****
- Removed labels: ****
Attachments:
from pyfpdf.
Hello,
unfortunately I worked on this issue not by forward engineering but with
reverse engineering (just to get a solution in an acceptable amount of time).
Therefore I did not check the 700 pages 1.3 spec before.
I generated the document with python 2.7, pyfpdf 1.7 and your patch. Symbol
U+010D (and also all symbols from Latin-1 Supplement and Latin extended-A) are
shown as expected with this viewers:
on Windows 7 with
- Adobe Acrobat Reader XI,
- Adobe Acrobat Pro X,
- FoxIt Reader 5.4,
- Google Chrome,
on Linux with
- evince,
- gimp import,
- xpdf,
on HP-UX with
- Adobe Acrobat Reader 5.0,
Original comment by [email protected]
on 23 Jan 2013 at 11:10
- Added labels: ****
- Removed labels: ****
from pyfpdf.
Edwin, 1.7 ref is about 1300, by the way :) I also didn't read full spec
carefully. yet.
I tested this patch with DejaVuSansCondensed, DroidSans an Ununtu-R fonts in
* evince (poppler library)
* atril (evince fork)
* Adobe Reader for android (This app also show U+010A instead of U+010D)
Look nice.
If there is no objection - i'll merge this patch.
Original comment by [email protected]
on 23 Jan 2013 at 11:27
- Added labels: ****
- Removed labels: ****
from pyfpdf.
I appreciate it.
Thank you!
Original comment by [email protected]
on 23 Jan 2013 at 12:25
- Added labels: ****
- Removed labels: ****
from pyfpdf.
Committed.
Edwin, thank you for reporting and proposed solution.
Original comment by [email protected]
on 25 Jan 2013 at 5:30
- Changed state: Fixed
- Added labels: ****
- Removed labels: ****
from pyfpdf.
Related Issues (20)
- ability to set the cell border size HOT 1
- twitter.png error HOT 9
- bullet in <ul> incompatible with utf-8 encoding HOT 4
- single quotes disappear
- Unicode problem in fpdf HOT 3
- Ln parameter of Cell does not work. Ln() default does not work. Multicell causes divide by zero fault. HOT 2
- FPDF' object has no attribute 'y' HOT 2
- Code39 does not work HOT 1
- Template.split_multicell push data before FPDF.add_page called HOT 2
- Patch for /fpdf/template.py HOT 6
- Patch for /fpdf/template.py HOT 2
- Printing Trademark (TM) symbol in PDF HOT 6
- "ouput" has default/hard-coded fonts location - throws I/O exception when different location used HOT 4
- Fail using easyinstall for MacOSX and python 3.4 HOT 4
- Integer division causes divide by zero error when units is 'in'. Errant code identified, but no patch supplied. HOT 2
- Web2py sample app has what should be view code in the controller, but is easily fixable HOT 1
- pyfpdf html to pdf mis-handles '<', '>', '&' and ' in tables. HOT 2
- Vertical align in cell
- get_string_width report wrong value for missed glyphs HOT 2
- PDF document blocked HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyfpdf.