Advertisement

[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

05/31/2005 at 07:55AM PDT, ID: 21441913
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

C# and Adobe SDK Watermark

Asked by mrwhipple in C# Programming Language, Macromedia Homesite, Adobe Type Manager

I have Adobe 7.0 SDK.  And I am trying to add a watermark to a pdf.  There is an example in VB that comes with the SDK, but I'm not very good at VB. I have tried to convert the VB code to C#, but some of the function do not seem to be available in C#.  

Here is the original Adobe sample code

Public Sub Main()

        ' Create a PDDoc IAC object.
        Dim pdDoc As Acrobat.CAcroPDDoc
        pdDoc = CreateObject("AcroExch.PDDoc")
        If pdDoc Is Nothing Then
            MsgBox("Failed to create Acrobat PDDoc object.")
            End
        End If

        ' Open the source PDF document
        Dim rc As Integer
        rc = pdDoc.Open(SamplePDFFilePath)
        If rc <> -1 Then
            MsgBox("Failed to open PDF document " & SamplePDFFilePath)
            End
        End If

        ' Acquire the Acrobat JavaScript Object interface from the PDDoc object
        jsObj = pdDoc.GetJSObject

        ' Add a watermark from a file.
        ' function prototype:
        '   addWatermarkFromFile(cDIPath, nSourcePage, nStart, nEnd, bOnTop, bOnScreen, bOnPrint, nHorizAlign, nVertAlign, nHorizValue, nVertValue, bPercentage, nScale, bFixedPrint, nRotation, nOpacity)
        jsObj.addWatermarkFromFile(SampleImageFilePath, 0, 0, 0, True, True, True, 0, 3, 10, -10, False, 0.4, False, 0, 0.7)

        ' get current time and make a string from it
        Dim currentTime As String
        currentTime = Now.ToString

        ' make a color object
        Dim oColor As Object
        oColor = jsObj.color.blue()

        ' Add a text watermark.
        ' function prototype:
        '   addWatermarkFromText(cText, nTextAlign, cFont, nFontSize, oColor, nStart, nEnd, bOnTop, bOnScreen, bOnPrint, nHorizAlign, nVertAlign, nHorizValue, nVertValue, bPercentage, nScale, bFixedPrint, nRotation, nOpacity)
        jsObj.addWatermarkFromText(currentTime, 1, "Helvetica", 10, oColor, 0, 0, True, True, True, 0, 3, 20, -45, False, 1.0, False, 0, 0.7)

        ' save the PDF with watermarks to a new document.
        rc = pdDoc.Save(1, OutputFilePath)  ' full save

        ' close original PDF.
        pdDoc.Close()
        pdDoc = Nothing
        jsObj = Nothing

        ' to clean up, get the Acrobat application,  
        ' close Acrobat if there are no open documents.
        Dim gApp As Acrobat.CAcroApp
        gApp = CreateObject("AcroExch.App")
        If gApp.GetNumAVDocs = 0 Then
            gApp.CloseAllDocs()
            gApp.Exit()
        End If

        ' show message. You can comment it out if you really need a quiet operation.
        If rc = True Then
            MsgBox("PDF with the watermark was saved to " & OutputFilePath)
        Else
            MsgBox("Operation was failed.")
        End If

    End Sub



When I try and run the code in VB it blows up right way on (pdDoc = CreateObject("AcroExch.PDDoc")).  In my converted C# code I do not have the addWatermarkFromFile function from the Adobe Javascript object.
Looking at the SDK help files I don't understand how I can access all the watermark functions they speak of.


What am I missing or doing wrong?   I think I am making this more difficult then it really is.


Thanks,
View the Solution FREE for 7 Days
[+][-]05/31/05 08:47 AM, ID: 14114317

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/31/05 12:43 PM, ID: 14116190

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/31/05 12:58 PM, ID: 14116336

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/31/05 02:02 PM, ID: 14116920

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/02/05 02:21 PM, ID: 14134843

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/23/05 11:41 AM, ID: 14287169

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/15/05 02:04 PM, ID: 14455024

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07/19/05 10:46 AM, ID: 14477582

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Macromedia Homesite, Adobe Type Manager
Sign Up Now!
Solution Provided By: GhostMod
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20090114-EE-VQP-51