Bug 707198 - -dPreserveAnnotTypes NOT Working
Summary: -dPreserveAnnotTypes NOT Working
Status: RESOLVED WORKSFORME
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: unspecified
Hardware: PC Windows 10
: P2 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-22 16:21 UTC by Geo-Van
Modified: 2023-09-24 07:42 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
Attachment as requested (139.91 KB, application/pdf)
2023-09-22 16:33 UTC, Geo-Van
Details
Attachment 2 as requested (135.88 KB, application/pdf)
2023-09-22 17:05 UTC, Geo-Van
Details
Attachment 3 as requested (140.91 KB, application/pdf)
2023-09-22 17:08 UTC, Geo-Van
Details
Output file (102.18 KB, application/pdf)
2023-09-23 08:36 UTC, Ken Sharp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Geo-Van 2023-09-22 16:21:06 UTC
-dPreserveAnnotTypes NOT Working

Taking a look under the PreserveAnnots switch here:
https://ghostscript.readthedocs.io/en/latest/VectorDevices.html#pdf-file-output-pdfwrite

Trying to apply the -dPreserveAnnotTypes is NOT working, for example lets try the following to preserve HYPERLINKS:
Example:
gs -dNOPAUSE -dQUIET -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf -c "/PreserveAnnotTypes [/Link] def" -f basic_link_1.pdf

BUT, please note that this is NOT working, unfortunately..... it flatten NOTHING, all annotations are NOT flatten, and hyperlinks are also NOT flatten.

Also we try the following, and it doesn't work either:
gs -dNOPAUSE -dQUIET -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf -dPreserveAnnots=false -c "/PreserveAnnotTypes [/Link] def" -f basic-link-1.pdf

Please see the relevant issue at:
#113

Can you please examine where is the error regarding -dPreserveAnnotTypes switch ?
Comment 1 Ken Sharp 2023-09-22 16:23:24 UTC
(In reply to Geo-Van from comment #0)

> Also we try the following, and it doesn't work either:
> gs -dNOPAUSE -dQUIET -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf
> -dPreserveAnnots=false -c "/PreserveAnnotTypes [/Link] def" -f
> basic-link-1.pdf
> 
> Please see the relevant issue at:
> #113
> 
> Can you please examine where is the error regarding -dPreserveAnnotTypes
> switch ?

You will have to supply a specimen file which demonstrates the problem.
Comment 2 Geo-Van 2023-09-22 16:33:12 UTC
Created attachment 24881 [details]
Attachment as requested

Please see Attachment as requested
Comment 3 Ken Sharp 2023-09-22 16:47:51 UTC
(In reply to Geo-Van from comment #2)
> Created attachment 24881 [details]
> Attachment as requested
> 
> Please see Attachment as requested

The attached file is overly complex, it contains 21 annotations just on page 1, all of which are Link annotations. So it's impossible to tell if annotation types other than Link are preserved or rendered.

How about attaching the actual file you were using instead of making an overly complicated new one.
Comment 4 Geo-Van 2023-09-22 17:05:32 UTC
Created attachment 24882 [details]
Attachment 2 [details] as requested
Comment 5 Geo-Van 2023-09-22 17:08:58 UTC
Created attachment 24883 [details]
Attachment 3 [details] as requested
Comment 6 Ken Sharp 2023-09-23 08:36:18 UTC
Created attachment 24887 [details]
Output file

(In reply to Geo-Van from comment #4)
> Created attachment 24882 [details]
> Attachment 2 [details] as requested

This file, again, only has Link annotations.

(In reply to Geo-Van from comment #5)
> Created attachment 24883 [details]
> Attachment 3 [details] as requested

Finally this one has both Link annotations non-Link annotations. Processing this file with:

-sDEVICE=pdfwrite -o new.pdf -c "/PreserveAnnotTypes [/Link] def" -f Specimen_3.pdf

Produces a file where the two Link annotations are preserved and the Square and Line annotations are rendered.
Comment 7 Geo-Van 2023-09-23 18:21:45 UTC
Thank you.

Please note that processing this file with:

-sDEVICE=pdfwrite -o new.pdf -c "/PreserveAnnotTypes [/Link] def" -f Specimen_3.pdf

Produces a file where the two Link annotations are preserved 
BUT,
the Square annotation is also preserved.
ONLY the Line annotation are rendered, unfortunately....

Can you please check again, - i think there is a bug regarding the -c "/PreserveAnnotTypes [/Link] def" -

Looking forward for your reply.
Comment 8 Ken Sharp 2023-09-23 18:51:52 UTC
(In reply to Geo-Van from comment #7)

> Produces a file where the two Link annotations are preserved 
> BUT,
> the Square annotation is also preserved.

No.

If you look at the file I attached you will see it has two Annots on page 1:

4 0 obj
<</Type/Page/MediaBox [0 0 841.92 594.96]
/Rotate 0/Parent 3 0 R
/Resources<</ProcSet[/PDF /Text]
/ExtGState 34 0 R
/Font 35 0 R
>>
/Annots[31 0 R
32 0 R]/Contents 5 0 R
>>
endobj


Both the listed Annotations are Link annotations:

31 0 obj
<</Type/Annot
/Border [0 0 0]
/F 4
/Rect [48.5862 523.411 208.653 534.217]
/StructParent 100000
/A<</S/URI
/Type/Action
/URI(https://www.autohotkey.com/boards/)>>
/Subtype/Link>>endobj

32 0 obj
<</Type/Annot
/Border [0 0 0]
/F 4
/Rect [48.5862 481.537 335.626 492.343]
/StructParent 100001
/A<</S/URI
/Type/Action
/URI(https://www.autohotkey.com/boards/viewtopic.php?f=76&t=37964)>>
/Subtype/Link>>endobj

There are no other annotations in the output file.


> Can you please check again, - i think there is a bug regarding the -c
> "/PreserveAnnotTypes [/Link] def" -

I disagree.
Comment 9 Geo-Van 2023-09-23 19:21:00 UTC
Yes you are right.
I use older version 10.0.0  , and in that version was not working.

But now i try latest version 10.02 , and YES!!! is working!!!

Many many thanks!
Comment 10 Ken Sharp 2023-09-24 07:42:42 UTC
(In reply to Geo-Van from comment #9)
> Yes you are right.
> I use older version 10.0.0  , and in that version was not working.

Well if you don't specify the version, there's no way I can know that. There is a field in the Bugzilla form for the version.....