logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

2 Pages<12
New Topic Post Reply
Options
Go to last post Go to first unread
Paul Rayman  
#21 Posted : Wednesday, June 26, 2019 6:52:29 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 909

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
Originally Posted by: rhnatiuk Go to Quoted Post
It seems that conversion from fake annotation to stream shrinks all contained objects. But this happens only to some files, like this one. Any ideas?


222.png

The problem is that the file contains an “unbalanced” zoom out matrix (line 21 in the screenshot)
And the text object, has the zoom in matrix (line 52)
The bounding box of the text object is obtained by multiplying these matrices.
When we add the path to the content of the page, this "unbalanced" matrix is ​​also applied to it (because it is not enclosed in the brackets of the stack operator - operator q..Q.
We must somehow compensate for this matrix, but I have not yet figured out how to do this, especially since a solution is needed in a general way.

So, if you add following
Code:
 pdfPathObject.Matrix = new FS_MATRIX(100 / 12f, 0, 0, 100 / 12f, 0, 0);

The path will shown in right place. But how to obtain these values....

Edited by user Wednesday, June 26, 2019 7:10:03 AM(UTC)  | Reason: Not specified

Paul Rayman  
#22 Posted : Wednesday, June 26, 2019 7:22:58 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 909

Thanks: 3 times
Was thanked: 110 time(s) in 107 post(s)
Originally Posted by: rhnatiuk Go to Quoted Post
It seems that conversion from fake annotation to stream shrinks all contained objects. But this happens only to some files, like this one. Any ideas?


I have one more idea.
You can eliminate the effect of drawing operators (as well as matrix operators) on your objects if you add your sinsert your stream as a first element of the contents array.

instead of
Code:
contentsArray.AddIndirect(list, stream);

use
Code:
contentsArray.Insert(...);


like shown below
Code:
var stream = PdfTypeStream.Create();
var list = PdfIndirectList.FromPdfDocument(doc);
int num = list.Add(stream);
....
contentsArray.Insert(0, PdfTypeIndirect.Create(list, num));


thanks 1 user thanked Paul Rayman for this useful post.
rhnatiuk on 6/26/2019(UTC)
rhnatiuk  
#23 Posted : Wednesday, June 26, 2019 7:40:24 AM(UTC)
Quote
rhnatiuk

Rank: Advanced Member

Groups: Registered
Joined: 4/30/2019(UTC)
Posts: 35
Man
Finland
Location: Raisio

Thanks: 9 times
Originally Posted by: Paul Rayman Go to Quoted Post
No, no

I mean following [...]


This one works, also on those "broken" files! :) I had to add AnnotationFlags.Locked | AnnotationFlags.LockedContents | AnnotationFlags.ReadOnly | AnnotationFlags.Print flags to all annotations (sad, that it is impossible to make annotations not selectable), but the result looks good. Probably we will go with this solution for now. Thank you!

rhnatiuk  
#24 Posted : Wednesday, June 26, 2019 8:25:57 AM(UTC)
Quote
rhnatiuk

Rank: Advanced Member

Groups: Registered
Joined: 4/30/2019(UTC)
Posts: 35
Man
Finland
Location: Raisio

Thanks: 9 times
Originally Posted by: Paul Rayman Go to Quoted Post
Originally Posted by: rhnatiuk Go to Quoted Post
It seems that conversion from fake annotation to stream shrinks all contained objects. But this happens only to some files, like this one. Any ideas?


I have one more idea.
You can eliminate the effect of drawing operators (as well as matrix operators) on your objects if you add your sinsert your stream as a first element of the contents array.

instead of
Code:
contentsArray.AddIndirect(list, stream);

use
Code:
contentsArray.Insert(...);



And yes, this works on "broken" PDFs as well!!! It is a bit faster than annotations-based solution as well. Thank you! We will use this approach!
Guest  
#25 Posted : Wednesday, September 2, 2020 4:55:35 AM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 148

Was thanked: 4 time(s) in 4 post(s)
Originally Posted by: Paul Rayman Go to Quoted Post


The problem is that the file contains an “unbalanced” zoom out matrix (line 21 in the screenshot)
And the text object, has the zoom in matrix (line 52)
The bounding box of the text object is obtained by multiplying these matrices.
When we add the path to the content of the page, this "unbalanced" matrix is ​​also applied to it (because it is not enclosed in the brackets of the stack operator - operator q..Q.
We must somehow compensate for this matrix, but I have not yet figured out how to do this, especially since a solution is needed in a general way.

。。。。


Do you now have a general solution to this “unbalanced matrices” problem?
Quick Reply Show Quick Reply
Users browsing this topic
2 Pages<12
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.