Giter VIP home page Giter VIP logo

Comments (5)

balacode avatar balacode commented on July 18, 2024

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.

balacode avatar balacode commented on July 18, 2024

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.

BrianHoldsworth avatar BrianHoldsworth commented on July 18, 2024

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.

balacode avatar balacode commented on July 18, 2024

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.

balacode avatar balacode commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.