PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jun 30, 2024 11:20 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Oct 02, 2012 1:34 pm 
Offline

Joined: Thu Aug 20, 2009 6:27 am
Posts: 14
hi guys,

i have a question to scanned PDF. I hope somebody here can help me find a way to solve this problem.

i imported a scanned PDF (1 image, no other content):
page.Size: Undefined
page.Orientation: Landscape
page.Width: {595pt}
page.Width.Centimeter: 20.990
page.Height: {837pt}
page.Height.Centimeter: 295.275
page.Rotate: 90
(before Orientation has been set, the Width and Height are swapped! see below!)

Its orientation is Landscape, but it is Portrait in every viewer.
So far no problem, but if i modify it (add watermark) and save,
its cutted to a square of 210x210mm (and the water mark on the bottom right isnt visible of course!)

I debugged it and i see that the Width and Height depends on the Orientation, but why?

Any ideas what im doing wrong? Or is it a bug?

Its strange that there is a rotation since its not landscape. but i think thats the way this old scanner worked in the 90's.
Any idea how to convert this type of PDF to "standard"?

Thanks in advance and BR
ToniM


edit_001:
the images are of type CCITTFaxDecode but unfortunatelly it seems there is no support from PdfSharp up to now ...
(http://forum.pdfsharp.net/viewtopic.php?f=4&t=82)


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 03, 2012 8:23 am 
Offline

Joined: Thu Aug 20, 2009 6:27 am
Posts: 14
It has nothing to do with the CCITTFaxDecode :( sorry for that!

i searched in the PDF file and there is following content (extract):
/CropBox [ 0 0 837 595 ]
/MediaBox [ 0 0 837 595 ]
/Rotate 90

and as i found out while debugging:
the page is per default Portrait, it ignores the width and height of the sheet, but in my opinion it should be Landscape.
(btw: Is there a PDF standard which says something about the orientation? or is it just used in PdfSharp?)

in my understanding it should be like this:
Width > Height = Landscape
others: Portrait

Please correct me if im wrong.

BR Martin


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 04, 2012 10:04 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
Hi!
ToniM wrote:
in my understanding it should be like this:
Width > Height = Landscape
others: Portrait
Sounds plausible.
But with Width > Height and Rotation = 90° you would have Protrait again, wouldn't you?

I do not know what the PDF Reference says about this.
But I know from experience that not all PDF creators fully adhere to the PDF Reference.
And yes, there could be bug in PDFsharp with respect to Size, Rotation, Orientation.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 04, 2012 11:41 am 
Offline

Joined: Thu Aug 20, 2009 6:27 am
Posts: 14
Thomas Hoevel wrote:
But with Width > Height and Rotation = 90° you would have Protrait again, wouldn't you?


yes and there i think is the problem, because with this constellation its Landscape instead of Portrait!
Initially the PdfPage.Orientation is by default Portrait. Then the logic of the internal ctor makes it to Landscape despite Width > Height.

So i see the problem while reading the MediaBox. Here should we also set the initial Orientation and (as i think) we are done!
Or implement the logic to the internal ctor ...

what do you think?


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 30, 2012 11:50 am 
Offline

Joined: Thu Aug 20, 2009 6:27 am
Posts: 14
Are there any news for me?
Or maybe a good idea to start?

BR ToniM


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 70 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group