PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Important Notice: We regret to inform you that our free phpBB forum hosting service will be discontinued by the end of June 30, 2024. If you wish to migrate to our paid hosting service, please contact billing@hostonnet.com.
Issue with Watermark

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
dpsubi1



Joined: 06 Mar 2008
Posts: 10
Location: Tech-Tips-Now.com

PostPosted: Thu Mar 06, 2008 1:48 pm    Post subject: Issue with Watermark Reply with quote

Hi,

Today I downloaded PDFsharp and was trying to add watermark to PDFs. However, it works on few PDFs (which is supplied as sample PDFs) but not on the PDFs I use.

Please check the PDF:

rapidshare.com/files/97482847/13.zip

I tried that PDF with the sample code provided in PDFSharp (watermark). I haven't changed any code except the PDF file name. If I use the PDFs supplied with samples it works fine not with the file I use. I also copied my PDF to the PDFs folder.

It doesn't throw any error.

Please let me know how to fix the problem at the earliest.

Thank you
_________________
Subi
Back to top
View user's profile Send private message Visit poster's website
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Thu Mar 06, 2008 2:06 pm    Post subject: Re: Issue with Watermark Reply with quote

dpsubi1 wrote:
Today I downloaded PDFsharp and was trying to add watermark to PDFs. However, it works on few PDFs (which is supplied as sample PDFs) but not on the PDFs I use.

What you say ain't true - it's working as intended and it works with your document, too.
Just look at page 3 - there is a watermark.

The Watermark sample shows three different methods of adding watermarks. On pages 1 and 2 these watermarks are below the page contents. Since the pages in your document have no transparent areas, the watermarks are not visible.
Page 3 draws the watermark on top of the contents - this works with your file, too.

Create documents with transparent pages or use method 3 to add watermarks.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
dpsubi1



Joined: 06 Mar 2008
Posts: 10
Location: Tech-Tips-Now.com

PostPosted: Thu Mar 06, 2008 2:09 pm    Post subject: Reply with quote

I do not know how to create pdf with transparent areas (not sure what it means). I just created PDFs with Acrobat 6.0

I will give a try with 3rd method and will let you know.

Thanks for your immediate help.
_________________
Subi
Back to top
View user's profile Send private message Visit poster's website
dpsubi1



Joined: 06 Mar 2008
Posts: 10
Location: Tech-Tips-Now.com

PostPosted: Thu Mar 06, 2008 2:29 pm    Post subject: Reply with quote

Thanks a lot. It worked great Very Happy
_________________
Subi
Back to top
View user's profile Send private message Visit poster's website
dpsubi1



Joined: 06 Mar 2008
Posts: 10
Location: Tech-Tips-Now.com

PostPosted: Mon Mar 10, 2008 8:43 am    Post subject: new problem with landscape pages Reply with quote

Hello,

Thanks for fixing my previous problem.

it worked great. I have been using the third method as you said.

Now i was trying to add the watermark on landscape page. however once the output is generated the page is cut off.

please try the files from the link and use the third method to replicate the problem.

rapidshare.com/files/98386054/14-15.zip

I am not sure how i can fix this problem.

please help.

thanks
_________________
Subi
Back to top
View user's profile Send private message Visit poster's website
trih



Joined: 11 Mar 2008
Posts: 2

PostPosted: Tue Mar 11, 2008 5:50 pm    Post subject: Reply with quote

I dont know very much about this libary (started yesterday with it), but maybe I can help you anyway.

Have you tried to turn your pdf-page before watermarking it?

Something like this:

if (page.Orientation == PdfSharp.PageOrientation.Landscape)
{
page.Orientation = PdfSharp.PageOrientation.Portrait;
}

But dont forget to turn it back again after you have added the watermark. If I understood you wrong please post again.
Back to top
View user's profile Send private message
dpsubi1



Joined: 06 Mar 2008
Posts: 10
Location: Tech-Tips-Now.com

PostPosted: Wed Mar 12, 2008 1:51 am    Post subject: Reply with quote

nope. It doesn't work. I already tried.

Thanks anyway.
_________________
Subi
Back to top
View user's profile Send private message Visit poster's website
woody3k



Joined: 26 Jun 2008
Posts: 1

PostPosted: Thu Jun 26, 2008 2:56 am    Post subject: Reply with quote

Hi,

Ran into this same issue - watermarking an existing pdf with mixed portrait & landscape pages.

One quick solution is to rotate each landscape page, eg:
Code:
page.Orientation = PdfSharp.PageOrientation.Portrait;
page.Rotate = 0;

I also managed to get to the source of the problem, the following workaround allowed me to retain the rotated landscape pages as they were in the original document. The page.Size property was undefined for each page, and it needs to be set with the current PageSize value for the landscape pages to be saved correctly. A quick-fix function to find the correct PageSize value for the given page is:
Code:
 private void SetPageSize(PdfPage page)
{
    PageSize result = PageSize.Undefined;

    PageSize[] pageSizes = (PageSize[])Enum.GetValues(typeof(PageSize));
    foreach (PageSize pageSize in pageSizes)
    {
        if (pageSize == PageSize.Undefined)
            continue;

        try
        {
            XSize size = PageSizeConverter.ToSize(pageSize);
            if (page.Orientation == PageOrientation.Portrait)
            {
                if (size.Width == page.Width.Point && size.Height == page.Height.Point)
                {
                    result = pageSize;
                    break;
                }
            }
            else
            {
                if (size.Width == page.Height.Point && size.Height == page.Width.Point)
                {
                    result = pageSize;
                    break;
                }
            }
        }
        catch
        {
            //swallow argument exception - the PageSizeConverter does not define an actual size for this PageSize (eg. PageSize.Undefined)
        }
    }
    if (result != PageSize.Undefined)
        page.Size = result;
}

And call this function at the end of the watermarking loop passing the current page. I call it at the end of the loop as setting the page.Size property modifies the page rectangle, and this can mess up the page size if you call it at the start of the loop.

I think this qualifies as a bug - the saving of pages is dependent on the current page.Size value, but the value is not set when pages are loaded in - when the Size is Undefined, it seems like it defaults to Portrait sizes.

hth,

woody
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com