open pdf and draw c# : How to add text to a pdf file control SDK system web page wpf html console adobephotoshop7_scripting_guide5-part2044

Photoshop7.0ScriptingGuide
51
ScriptingPhotoshop
TheApplicationobject
3
InVisualBasicorVBScript,youcreateanduseareferencetotheApplication.Typically,you
wouldwrite:
Set appRef = CreateObject("Photoshop.Application")
IfusingVB,thiscanalsobedonebywriting:
Set appRef = New Photoshop.Application
InJavaScript,thereisnoapplicationobjectandtherefore,allpropertiesandmethodsofthe
applicationareaccessiblewithoutanyqualification.TogettheactivePhotoshopdocument,
write:
var docRef = activeDocument;
Onceyouhavetargetedyourapplication,youarereadytoworkwiththepropertiesand
commandsoftheapplicationobject.
Theactivedocument
Because“document1”doesnotalwaysindicatethefront-mostdocument,it’srecommended
thatyourscriptssetthecurrentoractivedocumentbeforeexecutinganyothercommands.To
dothis,usethe“currentdocument(ActiveDocument/activeDocument)”propertyonthe
applicationobject.
AS: set docRef to current document
VB: Set docRef = appRef.ActiveDocument
JS: docRef = activeDocument;
Youcanalsoswitchbackandforthbetweendocumentsbysettingtheactivedocument.
AS: set current document to document "My Document"
VB: appRef.ActiveDocument = appRef.Documents("My y Document")
JS: activeDocument = documents["My Document"];
Applicationpreferences
TheapplicationobjectcontainsapropertyforPhotoshoppreferences.Thepreferences
propertyisitselfanobjectandhasmanyproperties.Thenameofthepreferencesobjectforthe
threelanguagesisthefollowing:
AS: settings
VB: Preferences
JS: preferences
Thepropertiesinthepreferencesobjectcorrelatetothepreferencesfoundbydisplayingthe
Photoshop“Preferences”dialogintheuserinterface(selectthe“Edit>Preferences”menuin
thePhotoshopUI).
How to add text to a pdf file - insert text into PDF content in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
XDoc.PDF for .NET, providing C# demo code for inserting text to PDF file
add text to pdf using preview; adding text field to pdf
How to add text to a pdf file - VB.NET PDF insert text library: insert text into PDF content in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Providing Demo Code for Adding and Inserting Text to PDF File Page in VB.NET Program
adding text pdf; adding text to a pdf in reader
Photoshop7.0ScriptingGuide
52
ScriptingPhotoshop
TheApplicationobject
3
Displaydialogs
Itisimportanttobeabletocontroldialogsproperlyfromascript.Ifadialogisshownyour
scriptstopsuntilauserdismissesthedialog.Thisisnormallyfineinaninteractivescriptthat
expectsausertobesittingatthemachine.Butifyouhaveascriptthatrunsinan
unsupervisored(batch)modeyoudonotwantdialogstobedisplayedandstopyourscript.
Usingthedisplay dialogs(DisplayDialogs/displayDialogs)propertyonthe
applicationobjectyoucancontrolwhetherornotdialogsaredisplayed.
Ifyousetdisplay dialogsto always ( psDisplayAllDialogs/ALL ),Photoshop
willshowalluserrelateddialogs.Thisistypicallynotwhatyouwant.
Ifyousetdisplay dialogstoerror dialogs (DisplayErrorDialogs/ERROR),
thenonlydialogsrelatedtoerrorsareshown.Youwouldtypicallyusethissettingwhenyou
aredevelopingascriptorifyourscriptisaninteractiveonethatexpectsausertobesittingat
themachinewhilerunningthescript.
Ifyousetdisplay dialogs tonever ( DisplayNoDialogs/NO O ), thennodialogs
areshown.Ifanerroroccursitwillbereturnedasanerrortothescript.Seesection2.10.4,
“Errorhandling”onpage31 formoreinformationoncatchingerrors.
Openingadocument
Whenusingtheopencommandthereareanumberofspecifiableoptions.Theseoptionsare
groupedbyfiletypeintheprovidedopenoptionsclasses.Becausethetypeandcontentsofthe
fileyouareworkingonaffectshowitisopened,someoftheoptionvaluesmaynotalwaysbe
applicable.Italsomeansthatmanyoftheoptionvaluesdonothavewelldefineddefault
values.
Thebestwaytodeterminewhatvaluescanorshouldbeusedforopenistoperformanopen
commandfromtheuserinterface.Youcanthencopythevaluefromtheoptionsdialogtoyour
script.Youshouldperformacompleteopen operationbecausetherecanbemultipledialogs
presentedbeforethedocumentisactuallyopened.Ifyoucanceloneoftheopendialogs
withoutcompletingtheoperationyoucouldmissseeingadialogwhichcontainsvalues
neededinyourscript.
Specifyingfileformatstoopen
BecausePhotoshopsupportsmanydifferentfileformats,theOpencommandletsyouspecify
theformatofthedocumentyouareopening.Ifyoudonotspecifytheformat,Photoshopwill
inferthetypeoffileforyou.Here’showtoopenadocumentusingitsdefaulttype:
AS:
set theFile to alias "MyFile.psd"
open theFile
VB:
fileName = = "C:\MyFile.psd"
Set docRef = appRef.Open(fileName)
VB.NET PDF Text Extract Library: extract text content from PDF
this advanced PDF Add-On, developers are able to extract target text content from source PDF document and save extracted text to other file formats through VB
add editable text box to pdf; add text to pdf without acrobat
VB.NET PDF Password Library: add, remove, edit PDF file password
This VB.NET example shows how to add PDF file password with access permission setting. passwordSetting.IsAssemble = True ' Add password to PDF file.
adding text to a pdf; how to enter text in pdf
Photoshop 7.0 Scripting Guide
54
Scripting Photoshop
Document object
3
pdfOpenOptionsRef.Width = 200
pdfOpenOptionsRef.mode = psOpenRGB
pdfOpenOptionsRef.Resolution = 72
pdfOpenOptionsRef.ConstrainProportions = False
'Now open the file
Dim docRef As Photoshop.Document
Set docRef = appRef.Open(< a file path>, pdfOpenOptionsRef)
'Restore unit setting
appRef.Preferences.RulerUnits = originalRulerUnits
JS:
// Set the ruler units to pixels
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
// Get a reference to the file that we want to open
var fileRef = new File( < a file path > );
// Create a PDF option object
var pdfOpenOptions = new PDFOpenOptions;
pdfOpenOptions.antiAlias = true;
pdfOpenOptions.height = 100;
pdfOpenOptions.width = 200;
pdfOpenOptions.mode = OpenDocumentMode.RGB;
pdfOpenOptions.resolution = 72;
pdfOpenOptions.constrainProportions = false;
// Now open the file
open( fileRef, pdfOpenOptions );
// restore unit settings
preferences.rulerUnits = originalRulerUnits;
Because Photoshop cannot save all of the format types that it can open, the open document
types may be different from the save document types.
3.8 Document object
After you target the Photoshop application, the next object you will likely target is the
Documentobject.The Document objectcanrepresentanyopendocumentinPhotoshop.
C# PDF Password Library: add, remove, edit PDF file password in C#
This example shows how to add PDF file password with access permission setting. passwordSetting.IsAssemble = true; // Add password to PDF file.
add text to pdf document online; adding text to pdf reader
C# PDF insert image Library: insert images into PDF in C#.net, ASP
using RasterEdge.Imaging.Basic; using RasterEdge.XDoc.PDF; Have a try with this sample C#.NET code to add an image to the first page of PDF file.
adding text to a pdf in preview; add text to pdf document in preview
Photoshop 7.0 Scripting Guide
56
Scripting Photoshop
Document object
3
VB:
Dim appRef As New Photoshop.Application
Set jpgSaveOptions = CreateObject("Photoshop.JPEGSaveOptions")
jpgSaveOptions.EmbedColorProfile = True
jpgSaveOptions.FormatOptions = psStandardBaseline
jpgSaveOptions.Matte = psNoMatte
jpgSaveOptions.Quality = 1
appRef.ActiveDocument.SaveAs "c:\temp\myFile2", _
Options:=jpgSaveOptions, _
asCopy:=True, extensionType:=psLowercase
JS:
jpgFile = new File( "/Temp001.jpeg" );
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 1;
activeDocument.saveAs(jpgFile, jpgSaveOptions, true,
Extension.LOWERCASE);
3.8.2 Document information
APhotoshop document can be associated with additional information such as the author via
the “File > File Info”menu.
The information found in this menu-item is handled by theinfo (DocumentInfo)
object.To change the information, reference to theinfo object and set its properties as shown
below.
AS:
set docInfoRef to info of current document
set copyrighted of docInfoRef to copyrighted work
set owner url of docInfoRef to "http://www.adobe.com"
VB:
Set docInfoRef = docRef.Info
docInfoRef.Copyrighted = psCopyrightedWork
docInfoRef.OwnerUrl = "http://www.adobe.com"
JS:
docInfoRef = docRef.info;
docInfoRef.copyrighted = CopyrightedType.COPYRIGHTEDWORK;
docInfoRef.ownerUrl = "http://www.adobe.com";
C# PDF File Split Library: Split, seperate PDF into multiple files
page of your defined page number which starts from 0. For example, your original PDF file contains 4 pages. C# DLLs: Split PDF Document. Add necessary references
adding text to pdf form; add text boxes to pdf document
C# PDF File Merge Library: Merge, append PDF files in C#.net, ASP.
document splitting, PDF page reordering and PDF page image and text extraction Add necessary references In addition, C# users can append a PDF file to the end of
how to insert text into a pdf file; adding text to a pdf file
Photoshop 7.0 Scripting Guide
57
Scripting Photoshop
Document object
3
3.8.3 Document manipulation
TheDocument object is used to make modifications to the document image. By using the
Documentobjectyoucancrop,rotateorflipthecanvas,resizetheimageorcanvas,andtrim
the Image.
Because unit values are passed in when resizing an image, it is recommended that you first set
your ruler units prior to resizing. See section3.5.3,“Changingrulerandtypeunits”onpage48
for more information.
The examples in this section assume that the ruler units have been set to inches.
To resize the image so that it is four inches wide by four inches high, use the document's
resize (Resize/resize)command.
AS: resize image current document width 4 height t 4
VB: docRef.ResizeImage 4,4
JS: docRef.resizeImage( 4,4 );
Resizing the canvas is done similarly.
AS: resize canvas current document width 4 height t 4
VB: docRef.ResizeCanvas 4,4
JS: docRef.resizeCanvas( 4,4 4 );
To trim the excess space from a document, use thetrim (Trim/trim) command. The
example below will trim the top and bottom of the document.
AS:
trim current document basing trim on top left pixel ¬
with top trim and bottom trim without left trim and right trim
VB:
docRef.Trim Type:=psTopLeftPixel, Top:=True, Left:=False, _
Bottom:=True, Right:=False
JS:
docRef.trim(TrimType.TOPLEFT, true, false, true, false);
N
OTE
:
The crop command uses unit values. The examples below assume that the ruler unit is
set to pixels.
AS:
crop current document bounds {10, 20, 40, 50} angle 45 ¬
resolution 72 width 20 height 20
VB:
docRef.Crop Array(10,20,40,50), Angle:=45, Width:=20, _
Height:=20, Resolution:=72
Photoshop 7.0 Scripting Guide
58
Scripting Photoshop
Layer objects
3
JS:
docRef.crop (new Array(10,20,40,50), 45, 20, 20, 72);
To flip the canvas horizontally:
AS: flip canvas current document direction horizontal
VB: docRef.FlipCanvas psHorizontal
JS: docRef.flipCanvas(Direction.HORIZONTAL);
3.9 Layer objects
Photoshop has 2 types of layers: anart layer that can contain image contents and alayer
setthatcancontainzeroormoreartlayers.Scripts,likewise,havetwotypesoflayers: art
layer and layer set.
Both types of layers have common properties such as “visible.”The common attributes are
placed in a general “layer”class that both “art layer”and “layer set”inherits from.
When you create a layer you must specify whether you are creating an art layer or a layer set.
The following examples show how to create an art layer filled with red at the beginning of the
current document
AS:
tell application "Adobe Photoshop 7.0"
make new art layer at beginning of current document ¬
with properties {name:"MyBlendLayer", blend mode:normal}
select all current document
fill selection of current document with contents ¬
{class:RGB color, red:255, green:0, blue:0}
end tell
Photoshop 7.0 Scripting Guide
59
Scripting Photoshop
Layer objects
3
VB:
Dim appRef As Photoshop.Application
Set appRef = CreateObject("Photoshop.Application")
' Create a new art layer at the beginning of the current document
Dim docRef As Photoshop.Document
Dim layerObj As Photoshop.ArtLayer
Set docRef = appRef.ActiveDocument
Set layerObj = appRef.ActiveDocument.ArtLayers.Add
layerObj.Name = "MyBlendLayer"
layerObj.BlendMode = psNormalBlend
' Select all so we can apply a fill to the selection
appRef.ActiveDocument.Selection.SelectAll
' Create a color to be used with the fill command
Dim colorObj As Photoshop.SolidColor
Set colorObj = CreateObject("Photoshop.SolidColor")
colorObj.RGB.Red = 255
colorObj.RGB.Green = 100
colorObj.RGB.Blue = 0
' Now apply fill to the current selection
appRef.ActiveDocument.Selection.Fill colorObj
JS:
// Create a new art layer at the beginning of the current document
var layerRef = activeDocument.artLayers.add();
layerRef.name = "MyBlendLayer";
layerRef.blendMode = BlendMode.NORMAL;
// Select all so we can apply a fill to the selection
activeDocument.selection.selectAll;
// Create a color to be used with the fill command
var colorRef = new SolidColor;
colorRef.rgb.red = 255;
colorRef.rgb.green = 100;
colorRef.rgb.blue = 0;
// Now apply fill to the current selection
activeDocument.selection.fill(colorRef);
Photoshop 7.0 Scripting Guide
60
Scripting Photoshop
Layer objects
3
The following examples show how to create a layer set after the first layer in the current
document:
AS:
tell application "Adobe Photoshop 7.0"
make new layer set after layer 1 of current document
end tell
VB:
Dim appRef As Photoshop.Application
Set appRef = CreateObject("Photoshop.Application")
' Get a reference to the first layer in the document
Dim layerRef As Photoshop.Layer
Set layerRef = appRef.ActiveDocument.Layers(1)
' Create a new LayerSet (it will be created at the beginning of the
' document)
Dim newLayerSetRef As Photoshop.LayerSet
Set newLayerSetRef = appRef.ActiveDocument.LayerSets.Add
' Move the new layer to after the first layer
newLayerSetRef.MoveAfter layerRef
JS:
// Get a reference to the first layer in the document
var layerRef = activeDocument.layers[0];
// Create a new LayerSet (it will be created at the beginning of the
// document)
var newLayerSetRef = activeDocument.layerSets.add();
// Move the new layer to after the first layer
newLayerSetRef.moveAfter( layerRef );
An existing art layer can also be changed to a text layer if the existing layer is empty.
Conversely you can change a text layer to a normal layer. When you do this the text in the
layer is rasterized.
Documents you may be interested
Documents you may be interested