Giter Site home page Giter Site logo

Comments (4)

vanbroup avatar vanbroup commented on August 15, 2024

I can confirm this happens with some files but have not been able to identify the cause yet.

from pdfsign.

vanbroup avatar vanbroup commented on August 15, 2024

Signing fails if the document has more than one xref table (revisions).

from pdfsign.

vanbroup avatar vanbroup commented on August 15, 2024

This item count includes all objects of the document:

new_xref_size := "xref\n0 " + strconv.FormatInt(context.PDFReader.XrefInformation.ItemCount+4, 10) + "\n"

But only the (latest?) xref table entries are included in the xref new table.

Using the correct count for the xref does not seem to fix the problem.

Adding a new referencing xref table instead of including all items from the last table seems to be a cleaner approach but has not resulted in any success for now.

The ReaderXrefInformation only contains information about the entire document and probably needs to be updated to contain information about each xref table or stream:
https://github.com/digitorus/pdf/blob/master/read.go#L92

from pdfsign.

dhernandez avatar dhernandez commented on August 15, 2024

This code at the writeXrefTable function makes the trick, but it probably is not the best option:

func (context *SignContext) writeXrefTable() error {
	context.InputFile.Seek(context.PDFReader.XrefInformation.StartPos, 0)
	scanner := bufio.NewScanner(context.InputFile)
	scanner.Split(bufio.ScanWords)
	scanner.Scan() // This should be xref string
	scanner.Scan()
	first_object_id := scanner.Text()
	scanner.Scan()
	xref_items := scanner.Text()
	xref_items_i, _ := strconv.Atoi(xref_items)

	xref_size := fmt.Sprintf("xref\n%s %s\n", first_object_id, xref_items)
	new_xref_size := fmt.Sprintf("xref\n%s %s\n", first_object_id, fmt.Sprint(xref_items_i+4))
...
}

from pdfsign.

Related Issues (10)

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.