Giter Club home page Giter Club logo

Comments (8)

galkahana avatar galkahana commented on July 24, 2024 1

sent back a response via email.

from pdf-writer.

galkahana avatar galkahana commented on July 24, 2024

it's sort of by design.
appending pages only appends their graphic data. no interactive. supposed to function like image embedding.
you can extend the copying code to also add links (in PDF lingua they are part of "annotations").

here's an essay discussing how to do it with example code:
https://www.pdfhummus.com/post/45501619928/copying-pages-with-comments
while it deals with comments, the code just copies annotations in general, so - comments, links etc.

from pdf-writer.

Dykson avatar Dykson commented on July 24, 2024

CopyingPagesWithComments.cpp works great with a simple pdf file MakingComments.pdf from the example. If you change the pdf file to your own, an exception will be thrown. I tried different files. It works terribly for me

from pdf-writer.

galkahana avatar galkahana commented on July 24, 2024

if you're willing to send me a sample i can probably see what the problem is and provide you a working example.

from pdf-writer.

Dykson avatar Dykson commented on July 24, 2024

sample.pdf

Crashes on line 116
116. EStatusCodeAndObjectIDType result = copyingContext->CopyObject(annotationReference->mObjectID);

from pdf-writer.

galkahana avatar galkahana commented on July 24, 2024

hmmm.
I wasn't able to recreate the crash.
created a branch with the code and file as a test - galk.named_dests. created a test with the code of copyingpageswithcomments named AppendWithAnnotations.

generated this output file:
CopyingPagesWithComments.pdf

outside, web, links seem to work. other links - those that got into the file itself don't. ill explain why soon.

As to the error that you experienced, it might be that you have another file that fails on this if somehow the annotation is embedded into the annotation dictionary instead of only being referred to. the code can be arranged to solve this better (either by allowing direct references, or copying the annotation to a new indirect object)...but yeah it is a bit more sophisticated.

as for the problem i saw, that the links don't work, is partly why i didn't bother with links when embedding individual pages. you see, internal links (named destinations) are a global PDF file object, which means it doesnt sit in the page, but rather in the global PDF object (the catalog). so copying individual pages ain't gonna be enough, and any implementation which potentially copy just some of the pages will be faulty.

there are several paths out of this depending what's the end game with embedding the pages in a new document. If this is just one document and you mean to provide overlay on top of it...then best is to create a modified version of the PDF file instead of appending its pages one by one. if you want to merge multiple PDFs, then you will have to write a more sophisticated coed to allow merging such things as named destinations.

in any case there's 2 things here i saw:

  • the problem you saw that i wasn't able to recreate - maybe you were using a different file? in that case please provide it to me...maybe it's still a simpler scenario (like the one for comments, or if the links are just plain urls).
  • the problem i saw, which is simply because the code is not smart enough to handle named destinations...in which maybe tell me a bit more about what you intend to do with the PDF and we could consider the simplest solution to fit.

Cheers,
Gal.

from pdf-writer.

Dykson avatar Dykson commented on July 24, 2024

Yes, you're right, I rechecked the files and sent them to the mail

from pdf-writer.

Dykson avatar Dykson commented on July 24, 2024

Well, the proposed fixes worked, thank you

from pdf-writer.

Related Issues (20)

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.