Comments (5)
Thank you very much! I have now added it. Could you share the code you used to catch this? It could be used to create some unit tests, as there are none now and PDFs are finicky.
from one-file-pdf.
Also, observe the block below. It looks wrong: writing another /Info after the trailer. I'm going to dust off the PDF_Reference.pdf, and check the specs.
// write the trailer
pdf.write("trailer\n<</Size %d/Root 1 0 R", len(pdf.objOffsets))
if infoIndex > 0 {
pdf.write("/Info %d 0 R", infoIndex)
}
from one-file-pdf.
Yeah, I don't know how the "trailer" works but I took it to be a "Table of Contents" referring back to the /Type/Info object.
I am just doing simple ad-hoc testing. An automated test for a PDF generator will likely require a PDF parser.
A simpler alternative (no full parser) would be a test app designed to utilize all the generator's options, paired with simple grep
based checking for the right strings in the output. This bug could have been caught by utilize pdf.SetDocTitle, then grep'ing the output for "/Type/Info/Title", right?
from one-file-pdf.
I'll look into writing some tests, starting with the metadata. For tests, I'm thinking of disabling compression so the PDF will just be a long string, then strip all whitespaces from both the check and the generated strings. Then just compare the two. It could be a brittle test, but not too much to worry. Just a matter of figuring the right expected PDF layout first.
from one-file-pdf.
I checked some specs. The /Info I mentioned is part of the trailer, along with /Size and /Root, so It's OK for it to be there. It's just an index in the trailer to locate the info.
from one-file-pdf.
Related Issues (11)
- SaveFile method creates unreadable file HOT 4
- PNG embedding is slow
- NextLine() calc seems wrong
- Larger charset HOT 2
- Streaming mode
- ZapfDingbats icons not rendered on Debian Linux 9 (squeeze) - probably extraneous issue HOT 2
- Return error(s) where possible please HOT 7
- No support for simple color (RGB) PNG images HOT 8
- How to support Unicode in the PDF format? HOT 5
- png_images.pdf (demo) is larger than estimated HOT 1
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 one-file-pdf.