commit
c48739e9b3
@ -0,0 +1,168 @@
|
||||
<job id="SubsMacros-MSExcel">
|
||||
<script language="VBScript">
|
||||
Option Explicit
|
||||
On Error Resume Next
|
||||
Dim digitDict
|
||||
|
||||
digitDict = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
Dim docFileName, txtFileName
|
||||
If WScript.Arguments.Count < 2 Then
|
||||
MsgBox "Usage: SubsMacros-MSWord <doc file> <data file>"
|
||||
WScript.Quit
|
||||
End If
|
||||
docFileName = WScript.Arguments(0)
|
||||
txtFileName = WScript.Arguments(1)
|
||||
|
||||
'docFileName = "C:\Users\cloong\Desktop\新建文件夹\验证计划DVP&R-WFQ-R-19-008A.xlsm"
|
||||
'txtFileName = "C:\Users\cloong\Desktop\新建文件夹\变更通知单.docm.txt"
|
||||
|
||||
Dim fs, txtFile, line, data
|
||||
Set fs = CreateObject("Scripting.FileSystemObject")
|
||||
If fs.FileExists(docFileName) = False Then
|
||||
'WScript.Echo "File " & docFileName & " doesn't exist!"
|
||||
WScript.Quit
|
||||
End If
|
||||
If Not Right(docFileName, 5) = ".xlsm" Then
|
||||
'MsgBox "数据集引用文件 " & docFileName & " 扩展名不是.xlsm, 可能出现不正确结果. 建议将扩展名改为.xlsm"
|
||||
End If
|
||||
If fs.FileExists(txtFileName) = False Then
|
||||
'WScript.Echo "File " & txtFileName & " doesn't exist!"
|
||||
WScript.Quit
|
||||
End If
|
||||
Dim metaDic,nvpair,nv
|
||||
Set txtFile = fs.OpenTextFile(txtFileName)
|
||||
Set metaDic = CreateObject("Scripting.Dictionary") '将dataFile第一行的数据转换为metaDic
|
||||
line = txtFile.ReadLine
|
||||
data = Split(line, "|")
|
||||
For Each nvpair In data
|
||||
nv = Split(nvpair, "=")
|
||||
If UBound(nv) > 0 Then
|
||||
If Not metaDic.Exists(nv(0)) Then
|
||||
metaDic.Add nv(0), nv(1)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim excelApp, workbook, workSheet
|
||||
Set excelApp = CreateObject("Excel.Application")
|
||||
'excelApp.Visible = True
|
||||
Set workbook = excelApp.Workbooks.Open(docFileName)
|
||||
'For n=1 to workbook.Sheets.Count
|
||||
'Set workSheet = workbook.Sheets(n)
|
||||
|
||||
|
||||
'With workSheet
|
||||
'WScript.Echo workbook.Names.Count
|
||||
Dim NameItem,n,item,subvalue,attrName,ReferTo, Pos,subPos,col,row,range,sheetStr,pic
|
||||
For Each NameItem In workbook.Names
|
||||
'For Each NameItem in workbook.Names
|
||||
'Set NameItem = workbook.Names.item(n)
|
||||
'WScript.Echo NameItem.Name
|
||||
For Each item In data
|
||||
If item <> "" then
|
||||
subvalue = Split(item,"=")
|
||||
'WScript.Echo subvalue(0)
|
||||
If (Left(NameItem.Name, 3) = Left(subvalue(0), 3)) Then
|
||||
|
||||
'attrName = Right(subvalue(1), Len(subvalue(1))-1)
|
||||
'WScript.Echo subvalue(0)
|
||||
Pos = NameItem.Value
|
||||
|
||||
subPos = Split(Pos,"$")
|
||||
'WScript.Echo Pos
|
||||
'WScript.Echo subPos(2)
|
||||
range = subPos(1) & subPos(2)
|
||||
sheetStr = Mid(subPos(0),2 ,Len(subPos(0))-2)
|
||||
|
||||
|
||||
|
||||
if Right(subvalue(1), 4) = ".jpg" Or Right(subvalue(1), 4) = ".png" Or Right(subvalue(1), 5) = ".jpg," Or Right(subvalue(1), 5) = ".png,"Then
|
||||
Dim t,l,w,h,strs,str,Fso,i
|
||||
'WScript.Echo "插入图片"
|
||||
'Set Fso = CreateObject("Scripting.FileSystemObject")
|
||||
'WScript.Echo sheetStr
|
||||
workbook.Sheets(sheetStr).Select
|
||||
workbook.Sheets(sheetStr).Range(range).Select
|
||||
strs = Split(subvalue(1), ",")
|
||||
i=0
|
||||
On Error Resume Next
|
||||
For Each str In strs
|
||||
if(Right(str, 1) ="g") Then
|
||||
Set Fso=workbook.Sheets(sheetStr).Shapes.AddPicture(str, False, True,workbook.Sheets(sheetStr).Range(range).Left+i, workbook.Sheets(sheetStr).Range(range).Top+5, 60, 65)
|
||||
|
||||
Fso.Name="jkexcel"
|
||||
'Fso.ShapeRange.IncrementTop 5
|
||||
'Fso.ShapeRange.IncrementLeft i
|
||||
|
||||
i=i+40
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
|
||||
|
||||
excelApp.ActiveSheet.PageSetup.CenterHorizontally = 2/0.035
|
||||
excelApp.ActiveSheet.PageSetup.CenterVertically = 2/0.035
|
||||
Else
|
||||
'WScript.Echo subvalue(1)
|
||||
col= workbook.Sheets(sheetStr).Range(range).Column
|
||||
workbook.Sheets(sheetStr).cells(Int(subPos(2)),Int(col)).Value = subvalue(1)
|
||||
|
||||
End if
|
||||
|
||||
|
||||
End if
|
||||
End if
|
||||
Next
|
||||
Next
|
||||
|
||||
'End With
|
||||
'Next
|
||||
' With workSheet
|
||||
' Dim curRow, curCol, colCount,rowCount, cellValue, attrName, item, cellName, subvalue, NameItem
|
||||
' colCount = .UsedRange.Columns.count
|
||||
' rowCount = .UsedRange.Rows.count
|
||||
' Dim n
|
||||
' WScript.Echo .Names.count
|
||||
' For n= 1 To workSheet.Names.count
|
||||
' Set NameItem = workSheet.Names.item(n)
|
||||
' WScript.Echo NameItem.Name
|
||||
' WScript.Echo NameItem.Value
|
||||
' Next
|
||||
' For curRow = 1 To (rowCount+.UsedRange.Row) '遍历题头至题尾的每一行,将该行的每一个&attrName替换为metaDic.Item(attrName)
|
||||
' For curCol = 1 To (colCount+.UsedRange.Column)
|
||||
' For Each NameItem In workbook.Names
|
||||
' If .cells(curRow,curCol).Value <> "" Then
|
||||
' For Each item In data
|
||||
' subvalue = Split(item,"=")
|
||||
' If subvalue(0) = NameItem.Name Then
|
||||
' attrName = Right(subvalue(1), Len(subvalue(1))-1)
|
||||
' .cells(curRow,curCol)= attrName
|
||||
' End if
|
||||
' Next
|
||||
' End If
|
||||
' Next
|
||||
' Next
|
||||
' Next
|
||||
' End With
|
||||
|
||||
|
||||
If Err.Number > 0 Then
|
||||
WScript.Echo "脚本执行过程中发生了错误 '" & Err.Description & "', 很可能导致了不正确的结果, 请检查相应数据."
|
||||
End If
|
||||
workbook.Save
|
||||
|
||||
workbook.Close
|
||||
excelApp.Quit
|
||||
'WScript.Echo "end"
|
||||
WScript.Quit
|
||||
|
||||
|
||||
Function digitValue(hexStr)
|
||||
digitValue = InStr(digitDict, hexStr) - 1
|
||||
'WScript.Echo "Decode hex char " & hexStr & " to " & digitValue
|
||||
End Function
|
||||
|
||||
</script>
|
||||
</job>
|
@ -0,0 +1,221 @@
|
||||
<job id="SubsMacros-MSWord">
|
||||
<reference guid="{00020905-0000-0000-C000-000000000046}"/>
|
||||
<script language="VBScript">
|
||||
Option Explicit
|
||||
On Error Resume Next
|
||||
Dim digitDict
|
||||
digitDict = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
Dim fs, WshShell
|
||||
Set fs = CreateObject("Scripting.FileSystemObject")
|
||||
Set WshShell = WScript.CreateObject("WScript.Shell")
|
||||
|
||||
Dim docFileName, txtFileName
|
||||
If WScript.Arguments.Count < 2 Then
|
||||
MsgBox "Usage: SubsMacros-MSWord <doc file> <data file>"
|
||||
WScript.Quit
|
||||
End If
|
||||
docFileName = WScript.Arguments(0)
|
||||
txtFileName = WScript.Arguments(1)
|
||||
'docFileName = "C:\Users\cloong\Desktop\新建文件夹\新品立项报告书-WFQ-R-19-002A.docm"
|
||||
'txtFileName = "C:\Users\cloong\Desktop\新建文件夹\变更通知单.docm.txt"
|
||||
Dim wordApp
|
||||
'Do
|
||||
' Set wordApp = Nothing
|
||||
' Set wordApp = GetObject(, "Word.Application")
|
||||
' wordApp.Quit
|
||||
'Loop Until wordApp Is Nothing
|
||||
'Err.Clear
|
||||
'On Error Resume Next
|
||||
|
||||
Dim docFilePath, pathLen
|
||||
For pathLen = Len(docFileName) To 1 Step -1
|
||||
If Mid(docFileName, pathLen, 1) = "\" Then
|
||||
docFilePath = Left(docFileName, pathLen)
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
'WshShell.Run "cmd.exe /c del /f /ah " & docFilePath & "~*.doc"
|
||||
|
||||
Dim txtFile, line, data
|
||||
If fs.FileExists(docFileName) = False Then
|
||||
'WScript.Echo "File " & docFileName & " doesn't exist!"
|
||||
WScript.Quit
|
||||
End If
|
||||
If Not Right(docFileName, 4) = ".doc" Then
|
||||
If Not Right(docFileName, 5) = ".docm" Then
|
||||
'MsgBox "数据集引用文件 " & docFileName & " 扩展名不是.docm或doc, 可能出现不正确结果. 建议将扩展名改为.doc.docm"
|
||||
End If
|
||||
End If
|
||||
If fs.FileExists(txtFileName) = False Then
|
||||
'WScript.Echo "File " & txtFileName & " doesn't exist!"
|
||||
WScript.Quit
|
||||
End If
|
||||
|
||||
Set txtFile = fs.OpenTextFile(txtFileName)
|
||||
line = txtFile.ReadLine()
|
||||
txtFile.Close
|
||||
Set data = ReadObject(line)
|
||||
|
||||
Dim doc
|
||||
Dim docVar, varIndex
|
||||
Dim pages
|
||||
'Dim word, name, value, startPos, endPos,preword
|
||||
Set wordApp = CreateObject("Word.Application")
|
||||
'wordApp.Visible = True
|
||||
Set doc = wordApp.Documents.Open( docFileName )
|
||||
pages = doc.Windows(1).Panes(1).Pages.Count
|
||||
'WScript.Echo pages
|
||||
'检查所有的客户化属性,赋初值
|
||||
Dim intProp, cusProp
|
||||
For intProp = 1 To doc.CustomDocumentProperties.Count
|
||||
If doc.CustomDocumentProperties(intProp).Value = "" Then
|
||||
doc.CustomDocumentProperties(intProp).Value = " "
|
||||
End If
|
||||
Next
|
||||
|
||||
'更新属性值
|
||||
|
||||
Dim oShape
|
||||
Dim t, dataName, dataVal ,pic,str,pim,i,pageName
|
||||
Dim ObjSelection,wordRange
|
||||
On Error Resume Next
|
||||
For Each t In data
|
||||
On Error Resume Next
|
||||
dataName = t
|
||||
If Right(data(dataName), 4) =".jpg" Or Right(data(dataName), 4) =".png" Or Right(data(dataName), 5) =".jpg," Or Right(data(dataName), 5) =".png," Then
|
||||
'WScript.Echo "插入图片"
|
||||
'WScript.Echo data(dataName)
|
||||
|
||||
str = data(dataName)
|
||||
'WScript.Echo dataName
|
||||
Set wordRange =wordApp.selection.Goto( , , ,dataName)
|
||||
Set ObjSelection=wordApp.selection
|
||||
if err.number=0 Then
|
||||
On Error Resume Next
|
||||
if(Right(str, 1) ="g") Then
|
||||
Set pim = ObjSelection.InlineShapes.AddPicture(str)
|
||||
pim.Title="wfword"
|
||||
Set oShape = pim.ConvertToShape
|
||||
'oShape.WrapFormat.Type = WdWrapType.wdWrapTopButtom
|
||||
oShape.WrapFormat.Type = 3
|
||||
oShape.ZOrder 4
|
||||
oShape.WrapFormat.AllowOverlap = False
|
||||
End If
|
||||
End if
|
||||
'If (pages > 1) Then
|
||||
'For i = 1 to pages-1
|
||||
'pageName = dataName & i
|
||||
'WScript.Echo pageName
|
||||
'Set wordRange =wordApp.selection.Goto( , , ,pageName)
|
||||
'Set ObjSelection=wordApp.selection
|
||||
'if err.number=0 Then
|
||||
'On Error Resume Next
|
||||
'if(Right(str, 1) ="g") Then
|
||||
'Set pim =ObjSelection.InlineShapes.AddPicture(str)
|
||||
'pim.Title="wfword"
|
||||
'End If
|
||||
'End if
|
||||
'Next
|
||||
'End If
|
||||
err.Clear
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
|
||||
Dim aStory, aField
|
||||
For Each aStory In doc.StoryRanges
|
||||
For Each aField In aStory.Fields
|
||||
aField.Update
|
||||
Next
|
||||
Next
|
||||
|
||||
|
||||
Dim sh
|
||||
dim l1
|
||||
dim n1
|
||||
dim n2
|
||||
|
||||
On Error Resume Next
|
||||
For Each sh in doc.Shapes
|
||||
startPos = -1 : endPos = -1
|
||||
name=trim(sh.TextFrame.TextRange.text)
|
||||
|
||||
If left(name, 2) = "&[" and mid(name,len(name)-1,1) = "]" then
|
||||
l1=len(name)
|
||||
n1=right(name,l1-2)
|
||||
n2=left(n1,l1-4)
|
||||
name=n2
|
||||
|
||||
If data.Exists(name) Then
|
||||
value = data(name)
|
||||
|
||||
sh.TextFrame.TextRange.Text=value
|
||||
wordApp.Selection.Find.Execute wdReplaceAll
|
||||
'WScript.Echo "wordApp.Selection.Find.Execute wdReplaceAll"
|
||||
Else
|
||||
|
||||
value = "(?)"
|
||||
'WScript.Echo "(?)"
|
||||
'doc.Range(startPos-2, endPos+1).Text = value
|
||||
End If
|
||||
|
||||
' WScript.Echo "Substituting " & doc.Range(startPos, endPos).Text & " to " & value
|
||||
startPos = -1 : endPos = -1
|
||||
End If
|
||||
Next
|
||||
'On Error Goto 0
|
||||
'Err.Clear
|
||||
doc.Save
|
||||
'WScript.Echo "插入图片成功"
|
||||
doc.Close
|
||||
|
||||
wordApp.Quit
|
||||
'WshShell.Run "cmd.exe /c del /f /ah " & docFilePath & "~*.doc"
|
||||
'WScript.Echo "end"
|
||||
|
||||
If Err.Number > 0 Then
|
||||
' WScript.Echo "脚本执行过程中发生了错误 '" & Err.Description & "', 很可能导致了不正确的结果, 请检查相应数据."
|
||||
End If
|
||||
|
||||
Function ReadObject(dataline)
|
||||
Dim data, nvpair, nv
|
||||
Set ReadObject = CreateObject("Scripting.Dictionary")
|
||||
data = Split(dataline, "|")
|
||||
For Each nvpair In data
|
||||
nv = Split(nvpair, "=")
|
||||
If UBound(nv) >= 1 Then
|
||||
If Not ReadObject.Exists(nv(0)) Then
|
||||
ReadObject.Add nv(0), SubstEscSeq(nv(1))
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End Function
|
||||
|
||||
Function digitValue(hexStr)
|
||||
digitValue = InStr(digitDict, hexStr) - 1
|
||||
'WScript.Echo "Decode hex char " & hexStr & " to " & digitValue
|
||||
End Function
|
||||
|
||||
Function SubstEscSeq(str)
|
||||
Dim startPos, tokenPos, strLen
|
||||
SubstEscSeq = ""
|
||||
strLen = Len(str)
|
||||
startPos = 1
|
||||
Do While startPos < strLen
|
||||
tokenPos = InStr(startPos, str, "%")
|
||||
If tokenPos < 1 Then
|
||||
Exit Do
|
||||
End If
|
||||
SubstEscSeq = SubstEscSeq + Mid(str, startPos, tokenPos - startPos)
|
||||
'WScript.Echo "Hex token " & Mid(str, tokenPos, 3) & " decoded to asc value: " & digitValue(Mid(str, tokenPos+1, 1)) * 16 + digitValue(Mid(str, tokenPos+2, 1))
|
||||
SubstEscSeq = SubstEscSeq + Chr(digitValue(Mid(str, tokenPos+1, 1)) * 16 + digitValue(Mid(str, tokenPos+2, 1)))
|
||||
startPos = tokenPos + 3
|
||||
Loop
|
||||
SubstEscSeq = SubstEscSeq + Mid(str, startPos, strLen - startPos + 1)
|
||||
'WScript.Echo "Decoded string from " & str & " to " & SubstEscSeq
|
||||
End Function
|
||||
|
||||
</script>
|
||||
</job>
|
Binary file not shown.
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/core-renderer.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/iTextAsian.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/iTextAsianCmaps.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/itextpdf-5.0.6.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/ojdbc7.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -0,0 +1 @@
|
||||
/bin/
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>cn.net.connor.designtopart</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/cn/net/connor/plm/util/ExcelWriteTable1.java=UTF-8
|
||||
encoding//src/cn/net/connor/plm/util/ExcelWriteTable2.java=UTF-8
|
||||
encoding//src/cn/net/connor/plm/util/ExcelWriteTable3.java=UTF-8
|
@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
@ -0,0 +1,73 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Designtopart
|
||||
Bundle-SymbolicName: cn.net.connor.designtopart;singleton:=true
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: cn.net.connor.designtopart.Activator
|
||||
Eclipse-RegisterBuddy: k.util
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
com.teamcenter.rac.aifrcp;bundle-version="12000.3.0",
|
||||
com.teamcenter.rac.common;bundle-version="12000.3.0",
|
||||
com.teamcenter.rac.external;bundle-version="12000.3.0",
|
||||
com.teamcenter.rac.kernel;bundle-version="12000.3.0",
|
||||
com.teamcenter.rac.tcapps;bundle-version="12000.3.0",
|
||||
com.teamcenter.rac.ui;bundle-version="12000.3.0",
|
||||
com.teamcenter.rac.ui.commands;bundle-version="12000.3.0",
|
||||
com.teamcenter.rac.util;bundle-version="12000.3.0",
|
||||
k.util;bundle-version="1.0.0",
|
||||
TcSoaCoreLoose;bundle-version="12000.3.0",
|
||||
TcSoaCoreRac;bundle-version="12000.3.0",
|
||||
TcSoaCoreTypes;bundle-version="12000.3.0",
|
||||
org.apache.poi.315;bundle-version="3.15.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Automatic-Module-Name: cn.net.connor.designtopart
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: cn.net.connor.designtopart,
|
||||
cn.net.connor.designtopart.commands,
|
||||
cn.net.connor.designtopart.designtopart,
|
||||
com.connor.dfl.plm.util,
|
||||
oracle.core.lmx,
|
||||
oracle.core.lvf,
|
||||
oracle.jdbc,
|
||||
oracle.jdbc.aq,
|
||||
oracle.jdbc.babelfish,
|
||||
oracle.jdbc.connector,
|
||||
oracle.jdbc.dcn,
|
||||
oracle.jdbc.diagnostics,
|
||||
oracle.jdbc.driver,
|
||||
oracle.jdbc.internal,
|
||||
oracle.jdbc.oci,
|
||||
oracle.jdbc.oracore,
|
||||
oracle.jdbc.pool,
|
||||
oracle.jdbc.pooling,
|
||||
oracle.jdbc.proxy,
|
||||
oracle.jdbc.proxy.annotation,
|
||||
oracle.jdbc.replay,
|
||||
oracle.jdbc.replay.driver,
|
||||
oracle.jdbc.replay.internal,
|
||||
oracle.jdbc.rowset,
|
||||
oracle.jdbc.util,
|
||||
oracle.jdbc.xa,
|
||||
oracle.jdbc.xa.client,
|
||||
oracle.jpub.runtime,
|
||||
oracle.net.ano,
|
||||
oracle.net.aso,
|
||||
oracle.net.jdbc.TNSAddress,
|
||||
oracle.net.jdbc.nl,
|
||||
oracle.net.jdbc.nl.mesg,
|
||||
oracle.net.jndi,
|
||||
oracle.net.ns,
|
||||
oracle.net.nt,
|
||||
oracle.net.resolver,
|
||||
oracle.security.o3logon,
|
||||
oracle.security.o5logon,
|
||||
oracle.sql,
|
||||
oracle.sql.converter
|
||||
Bundle-ClassPath: .,
|
||||
lib/ojdbc7.jar,
|
||||
lib/core-renderer.jar,
|
||||
lib/iTextAsian.jar,
|
||||
lib/iTextAsianCmaps.jar,
|
||||
lib/itextpdf-5.0.6.jar
|
||||
Import-Package: com.teamcenter.rac.ui.common
|
@ -0,0 +1,11 @@
|
||||
output.. = bin/
|
||||
bin.includes = plugin.xml,\
|
||||
META-INF/,\
|
||||
icons/,\
|
||||
.,\
|
||||
lib/ojdbc7.jar,\
|
||||
lib/core-renderer.jar,\
|
||||
lib/iTextAsian.jar,\
|
||||
lib/iTextAsianCmaps.jar,\
|
||||
lib/itextpdf-5.0.6.jar
|
||||
source.. = src/
|
Binary file not shown.
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 526 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension point="org.eclipse.ui.commands">
|
||||
<command name="图纸创建物料" id="cn.net.connor.designtopart.commands.DesignToPartCommand"/>
|
||||
<command name="数据发放" id="cn.net.connor.designtopart.commands.DataAllocationCommand"></command>
|
||||
</extension>
|
||||
|
||||
|
||||
<extension point="org.eclipse.ui.handlers">
|
||||
<handler commandId="cn.net.connor.designtopart.commands.DesignToPartCommand" class="k.KHandler"/>
|
||||
<handler class="cn.net.connor.plm.handlers.DataAllocationHandler" commandId="cn.net.connor.designtopart.commands.DataAllocationCommand"></handler>
|
||||
</extension>
|
||||
|
||||
|
||||
<extension point="org.eclipse.ui.menus">
|
||||
<menuContribution locationURI="menu:custWJ?after=projectCust">
|
||||
<command commandId="cn.net.connor.designtopart.commands.DesignToPartCommand" id="cn.net.connor.designtopart.menu.designtopart"/>
|
||||
</menuContribution>
|
||||
|
||||
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?before=additions">
|
||||
<command commandId="cn.net.connor.designtopart.commands.DataAllocationCommand" mnemonic="S" icon="icons/refresh_16.png" id="com.LINIX.sap.commands.batchDownload">
|
||||
<visibleWhen>
|
||||
<and>
|
||||
<or>
|
||||
<reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/>
|
||||
<reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
|
||||
</or>
|
||||
<iterate ifEmpty="false">
|
||||
<adapt type="com.teamcenter.rac.kernel.TCComponent">
|
||||
<!-- A8_ProductRevision==> 指定版本类型-->
|
||||
<test property="com.teamcenter.rac.kernel.TCComponent.type" value="DocumentRevision" />
|
||||
</adapt>
|
||||
</iterate>
|
||||
<with variable="rac_command_suppression">
|
||||
<not>
|
||||
<iterate operator="or"><equals value="com.nancal.XXXHandler" /> </iterate>
|
||||
</not>
|
||||
</with>
|
||||
</and>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
</plugin>
|
@ -0,0 +1,44 @@
|
||||
package cn.net.connor.designtopart;
|
||||
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "cn.net.connor.designtopart"; //$NON-NLS-1$
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.net.connor.designtopart;
|
||||
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
|
||||
public class DesigntopartLocale {
|
||||
|
||||
public static final Registry reg = Registry.getRegistry(DesigntopartLocale.class);
|
||||
|
||||
public static String getString(String title) {
|
||||
if (isEmpty(title)) {
|
||||
return "";
|
||||
} else {
|
||||
String res = reg.getString(title);
|
||||
return isEmpty(res) ? title : res;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isEmpty(String title) {
|
||||
return title == null || "".equals(title.trim());
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.net.connor.designtopart.commands;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
|
||||
import cn.net.connor.designtopart.designtopart.DesignToPartDialog;
|
||||
import cn.net.connor.designtopart.designtopart.DesignToPartDialogController;
|
||||
import k.KCommand;
|
||||
|
||||
public class DesignToPartCommand extends KCommand {
|
||||
|
||||
public DesignToPartCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
|
||||
super(app, commandId, actionInfo);
|
||||
this.setRunnable(new DesignToPartDialog(new DesignToPartDialogController(app)));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.net.connor.designtopart.designtopart;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import cn.net.connor.designtopart.DesigntopartLocale;
|
||||
import javafx.embed.swing.JFXPanel;
|
||||
import k.KDialog;
|
||||
import k.KDialogController;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class DesignToPartDialog extends KDialog {
|
||||
|
||||
protected DesignToPartDialogController controller;
|
||||
|
||||
public DesignToPartDialog(KDialogController controller) {
|
||||
super(controller);
|
||||
this.controller = (DesignToPartDialogController) controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addListeners() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initUI() {
|
||||
this.setTitle(DesigntopartLocale.getString("designtopart"));
|
||||
this.setPreferredSize(new Dimension(800, 600));
|
||||
this.setMinimumSize(new Dimension(800, 600));
|
||||
JFXPanel panel = new JFXPanel();
|
||||
panel.setScene(new DesignToPartPanel(this).getScene());
|
||||
this.add(BorderLayout.CENTER, panel);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package cn.net.connor.designtopart.designtopart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
|
||||
import cn.net.connor.designtopart.DesigntopartLocale;
|
||||
import k.KDialogController;
|
||||
import k.util.KUtil;
|
||||
|
||||
public class DesignToPartDialogController extends KDialogController {
|
||||
|
||||
public static final String PREF_TRANSFER = DesigntopartLocale.getString("DESIGNTOPART.PREF");
|
||||
protected List<TableBuilder> tableBuilders = new ArrayList<TableBuilder>();
|
||||
|
||||
public DesignToPartDialogController(AbstractAIFApplication app) {
|
||||
super(app);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
InterfaceAIFComponent[] targets = app.getTargetComponents();
|
||||
Map<String, List<TCComponentItemRevision>> selectedRevMap = new HashMap<>(64);
|
||||
int targetCnt = KUtil.getLen(targets);
|
||||
for (int i = 0; i < targetCnt; i++) {
|
||||
InterfaceAIFComponent target = targets[i];
|
||||
if (!(target instanceof TCComponentItemRevision)) {
|
||||
continue;
|
||||
}
|
||||
TCComponentItemRevision rev = (TCComponentItemRevision) target;
|
||||
String type = rev.getType();
|
||||
List<TCComponentItemRevision> list;
|
||||
if (selectedRevMap.containsKey(type)) {
|
||||
list = selectedRevMap.get(type);
|
||||
} else {
|
||||
list = new ArrayList<TCComponentItemRevision>();
|
||||
selectedRevMap.put(type, list);
|
||||
}
|
||||
if (!list.contains(rev)) {
|
||||
list.add(rev);
|
||||
}
|
||||
}
|
||||
selectedRevMap.forEach((k, v) -> System.out.println("ÀàÐÍ = " + k + ", " + v));
|
||||
if (selectedRevMap.size() == 0) {
|
||||
throw new TCException(DesigntopartLocale.getString("selectrev.INFO"));
|
||||
}
|
||||
// Connor_Design_To_Part
|
||||
String[] prefVals = KUtil.getPrefVals(session, PREF_TRANSFER);
|
||||
int len = KUtil.getLen(prefVals);
|
||||
int counter = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
String prefVal = prefVals[i];
|
||||
TableBuilder builder = new TableBuilder(session, prefVal, selectedRevMap);
|
||||
tableBuilders.add(builder);
|
||||
counter += (builder.fromRevList == null ? 0 : builder.fromRevList.size());
|
||||
}
|
||||
if (tableBuilders.size() == 0) {
|
||||
throw new TCException(String.format(DesigntopartLocale.getString("pref.ERROR1"), PREF_TRANSFER));
|
||||
}
|
||||
if (counter == 0) {
|
||||
throw new TCException(DesigntopartLocale.getString("notransferdata.INFO"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0"
|
||||
xmlns="http://javafx.com/javafx/8"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="cn.net.connor.designtopart.designtopart.DesignToPartPanelController">
|
||||
<children>
|
||||
<BorderPane prefHeight="200.0" prefWidth="200.0">
|
||||
<center>
|
||||
<ScrollPane fx:id="scrollPane" fitToHeight="true" fitToWidth="true" prefViewportHeight="400.0" prefViewportWidth="600.0" styleClass="edge-to-edge" BorderPane.alignment="CENTER">
|
||||
<content>
|
||||
<VBox fx:id="vBox" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="150.0" spacing="12.0">
|
||||
<padding>
|
||||
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
|
||||
</padding>
|
||||
</VBox>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</center>
|
||||
<bottom>
|
||||
<GridPane alignment="CENTER" hgap="50.0" BorderPane.alignment="CENTER">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
|
||||
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Button mnemonicParsing="false" onAction="#createBtnClick" text=" 创建 " />
|
||||
<Button mnemonicParsing="false" onAction="#closeBtnClick" text=" 取消 " GridPane.columnIndex="1" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
|
||||
</padding>
|
||||
</GridPane>
|
||||
</bottom>
|
||||
</BorderPane>
|
||||
<AnchorPane fx:id="cover" prefHeight="600.0" prefWidth="800.0" visible="false">
|
||||
<children>
|
||||
<ProgressIndicator prefHeight="30.0" prefWidth="30.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</StackPane>
|
@ -0,0 +1,14 @@
|
||||
package cn.net.connor.designtopart.designtopart;
|
||||
|
||||
import java.awt.Window;
|
||||
|
||||
import k.ui.KFXPanel;
|
||||
|
||||
public class DesignToPartPanel extends KFXPanel{
|
||||
|
||||
public DesignToPartPanel(Window dialog) {
|
||||
super(dialog, DesignToPartPanel.class, "style.css");
|
||||
initData();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
package cn.net.connor.designtopart.designtopart;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
import cn.net.connor.designtopart.DesigntopartLocale;
|
||||
import cn.net.connor.designtopart.designtopart.TableBuilder.RowData;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TitledPane;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.VBox;
|
||||
import k.KOperation;
|
||||
import k.KOperation2;
|
||||
import k.ui.KFXPanel;
|
||||
import k.ui.KFXPanelController;
|
||||
import k.util.KUtil;
|
||||
|
||||
public class DesignToPartPanelController extends KFXPanelController {
|
||||
@FXML
|
||||
private AnchorPane cover;
|
||||
@FXML
|
||||
private VBox vBox;
|
||||
@FXML
|
||||
private ScrollPane scrollPane;
|
||||
|
||||
private DesignToPartDialog dialog;
|
||||
private List<TableBuilder> tableBuilders;
|
||||
protected boolean flag = false;
|
||||
protected double scrollVal;
|
||||
|
||||
@Override
|
||||
public void initData(KFXPanel panel) throws Exception {
|
||||
this.dialog = (DesignToPartDialog) ((DesignToPartPanel) panel).getParentDialog();
|
||||
this.tableBuilders = dialog.controller.tableBuilders;
|
||||
setProgressVisible(true);
|
||||
|
||||
new KOperation(AIFUtility.getCurrentApplication(), DesigntopartLocale.getString("readdata.STATUS")) {
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
int tableBuilderCnt = tableBuilders.size();
|
||||
for (int i = 0; i < tableBuilderCnt; i++) {
|
||||
TableBuilder tableBuilder = tableBuilders.get(i);
|
||||
TableView<RowData> table = tableBuilder.build();
|
||||
if (table == null) {
|
||||
continue;
|
||||
}
|
||||
table.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent mouseEvent) {
|
||||
flag = true;
|
||||
scrollVal = scrollPane.getVvalue();
|
||||
scrollPane.setVvalue(scrollVal);
|
||||
System.out.println("---MOUSE_CLICKED---");
|
||||
}
|
||||
});
|
||||
|
||||
Platform.runLater(() -> {
|
||||
TitledPane pane = new TitledPane(tableBuilder.title, table);
|
||||
int height = (100 + 35 * tableBuilder.fromRevList.size()) > 205
|
||||
? (100 + 35 * tableBuilder.fromRevList.size())
|
||||
: 205;
|
||||
pane.setMinHeight(170);
|
||||
pane.setMaxHeight(height);
|
||||
pane.expandedProperty().addListener((observable, wasExpanded, isExpanded) -> {
|
||||
pane.setMaxHeight(isExpanded ? height : 0);
|
||||
pane.setMinHeight(isExpanded ? 230 : Region.USE_PREF_SIZE);
|
||||
});
|
||||
pane.setAnimated(false);
|
||||
VBox.setVgrow(pane, Priority.ALWAYS);
|
||||
vBox.getChildren().add(pane);
|
||||
});
|
||||
}
|
||||
setProgressVisible(false);
|
||||
}
|
||||
}.executeModeless();
|
||||
|
||||
scrollPane.vvalueProperty()
|
||||
.addListener((ObservableValue<? extends Number> ov, Number old_val, Number new_val) -> {
|
||||
if (flag) {
|
||||
scrollPane.setVvalue(scrollVal);
|
||||
flag = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void closeBtnClick() {
|
||||
dialog.disposeDialog();
|
||||
}
|
||||
|
||||
public void createBtnClick() {
|
||||
setProgressVisible(true);
|
||||
new KOperation2(AIFUtility.getCurrentApplication(), DesigntopartLocale.getString("create.STATUS")) {
|
||||
|
||||
@Override
|
||||
public boolean init() throws Exception {
|
||||
try {
|
||||
checkCanCreate();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(dialog, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
doCreate();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
MessageBox.post(dialog, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCache() throws Exception {
|
||||
setProgressVisible(false);
|
||||
}
|
||||
|
||||
}.executeModeless();
|
||||
|
||||
}
|
||||
|
||||
public void checkCanCreate() throws Exception {
|
||||
for (int i = 0; i < tableBuilders.size(); i++) {
|
||||
tableBuilders.get(i).checkCanCreate();
|
||||
}
|
||||
}
|
||||
|
||||
public void doCreate() throws Exception {
|
||||
StringBuilder err = new StringBuilder();
|
||||
for (int i = 0; i < tableBuilders.size(); i++) {
|
||||
TableBuilder tableBuilder = tableBuilders.get(i);
|
||||
String status = tableBuilder.title + ": " + DesigntopartLocale.getString("create.STATUS");
|
||||
try {
|
||||
tableBuilder.doCreate(status);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
err.append("[" + tableBuilder.title + "]" + e.getMessage() + "\r\n");
|
||||
}
|
||||
}
|
||||
if (err.length() > 0) {
|
||||
String errTitle = DesigntopartLocale.getString("createerror.TITLE");
|
||||
String exportFileName = errTitle + KUtil.getDateStr(new Date(), "_yyyyMMdd_HHmmss") + ".txt";
|
||||
KUtil.showScrollDialogWithExport(dialog, err.toString(), errTitle, exportFileName);
|
||||
} else {
|
||||
KUtil.info(dialog, DesigntopartLocale.getString("create.SUCCESS"));
|
||||
}
|
||||
}
|
||||
|
||||
public void setProgressVisible(boolean visible) {
|
||||
if (cover != null) {
|
||||
if (Platform.isFxApplicationThread()) {
|
||||
cover.setVisible(visible);
|
||||
} else {
|
||||
Platform.runLater(() -> {
|
||||
cover.setVisible(visible);
|
||||
});
|
||||
}
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(20);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
.table-view {
|
||||
-fx-faint-focus-color: transparent;
|
||||
-fx-focus-color: rgba(0, 0, 0, 0.2);
|
||||
-fx-background-insets: 0;
|
||||
}
|
||||
|
||||
.redcell:filled {
|
||||
-fx-background-color: #f5696c;
|
||||
-fx-background-insets: 0.5;
|
||||
}
|
||||
|
||||
.table-view:row-selection .table-row-cell:selected .redcell {
|
||||
-fx-background-color: null;
|
||||
}
|
||||
|
||||
.table-view:cell-selection .redcell:selected {
|
||||
-fx-background-color: -fx-table-cell-border-color, -fx-background;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#
|
||||
#Wed Dec 23 10:14:08 CST 2020
|
||||
designtopart=Design To Part
|
||||
DESIGNTOPART.PREF=Connor_Design_To_Part
|
||||
notransferdata.INFO=\u6CA1\u6709\u627E\u5230\u53EF\u4EE5\u8F6C\u6362\u7684\u7C7B\u578B
|
||||
propnotdefinedintype.ERROR2=\u5C5E\u6027"%s"\u672A\u5728\u7C7B\u578B"%s"\u4E2D\u5B9A\u4E49
|
||||
create.SUCCESS=\u56FE\u7EB8\u8F6C\u7269\u6599\u5B8C\u6210
|
||||
selectrev.INFO=\u672A\u9009\u62E9\u7248\u672C\u7C7B\u578B
|
||||
prefvalue.ERROR1=\u65E0\u6CD5\u89E3\u6790\u9996\u9009\u9879\u914D\u7F6E "%s"
|
||||
create.STATUS=\u56FE\u7EB8\u8F6C\u7269\u6599
|
||||
prefconfig.EMPTY=\u914D\u7F6E\u4E0D\u53EF\u4E3A\u7A7A
|
||||
readdata.STATUS=\u52A0\u8F7D\u6570\u636E
|
||||
createerror.TITLE=\u56FE\u7EB8\u8F6C\u7269\u6599\u9519\u8BEF
|
||||
tablerowdataempty.ERROR2="%s"\u8868\u7B2C%d\u884C\u5FC5\u586B\u5C5E\u6027\u5B58\u5728\u7A7A\u503C\uFF0C\u8BF7\u5B8C\u5584\u540E\u518D\u6267\u884C\u521B\u5EFA
|
||||
pref.ERROR1=\u9996\u9009\u9879"%s"\u914D\u7F6E\u9519\u8BEF
|
@ -0,0 +1,15 @@
|
||||
#
|
||||
#Wed Dec 23 10:14:08 CST 2020
|
||||
designtopart=\u56FE\u7EB8\u8F6C\u7269\u6599
|
||||
DESIGNTOPART.PREF=Connor_Design_To_Part
|
||||
notransferdata.INFO=\u6CA1\u6709\u627E\u5230\u53EF\u4EE5\u8F6C\u6362\u7684\u7C7B\u578B
|
||||
propnotdefinedintype.ERROR2=\u5C5E\u6027"%s"\u672A\u5728\u7C7B\u578B"%s"\u4E2D\u5B9A\u4E49
|
||||
create.SUCCESS=\u56FE\u7EB8\u8F6C\u7269\u6599\u5B8C\u6210
|
||||
selectrev.INFO=\u672A\u9009\u62E9\u7248\u672C\u7C7B\u578B
|
||||
prefvalue.ERROR1=\u65E0\u6CD5\u89E3\u6790\u9996\u9009\u9879\u914D\u7F6E "%s"
|
||||
create.STATUS=\u56FE\u7EB8\u8F6C\u7269\u6599
|
||||
prefconfig.EMPTY=\u914D\u7F6E\u4E0D\u53EF\u4E3A\u7A7A
|
||||
readdata.STATUS=\u52A0\u8F7D\u6570\u636E
|
||||
createerror.TITLE=\u56FE\u7EB8\u8F6C\u7269\u6599\u9519\u8BEF
|
||||
tablerowdataempty.ERROR2="%s"\u8868\u7B2C%d\u884C\u5FC5\u586B\u5C5E\u6027\u5B58\u5728\u7A7A\u503C\uFF0C\u8BF7\u5B8C\u5584\u540E\u518D\u6267\u884C\u521B\u5EFA
|
||||
pref.ERROR1=\u9996\u9009\u9879"%s"\u914D\u7F6E\u9519\u8BEF
|
@ -0,0 +1,173 @@
|
||||
package cn.net.connor.plm.handlers;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import cn.net.connor.plm.dialogs.DataAllocationHandlerDialog;
|
||||
import cn.net.connor.plm.entity.Prop;
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class DataAllocationHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
// TODO Auto-generated method stub
|
||||
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
|
||||
|
||||
TCComponent rev = (TCComponent) app.getTargetComponent();
|
||||
try {
|
||||
TCComponent[] components = rev.getRelatedComponents("SB6_XGWJ");
|
||||
|
||||
String[] type1 = { "SB6_CatiaDesignXRevision", "SB6_AutocadDXRevision", "SB6_CatiaAssDXRevision",
|
||||
"SB6_CatiaSDXRevision", "SB6_AutocadAssDXRevision", "SB6_AutocadSDXRevision",
|
||||
"SB6_CatiaDesignLRevision", "SB6_AutocadDLRevision", "SB6_CatiaAssDLRevision",
|
||||
"SB6_CatiaSDLRevision", "SB6_AutocadAssDLRevision", "SB6_AutocadSDLRevision" };
|
||||
String type3 = "SB6_SZLXDRevisionMaster";
|
||||
|
||||
String[] prop1 = { "object_name", "item_id", "item_revision_id" };
|
||||
String[] prop3 = { "sb6_SZRM01", "sb6_SZRM02", "sb6_SZRM03", "sb6_SZRM04"};
|
||||
|
||||
// 获取当前本地日期和时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd");
|
||||
String localTime = now.format(formatter);
|
||||
System.out.println("localTime : "+ localTime);
|
||||
|
||||
List<Prop> propList1 = new ArrayList<>();
|
||||
List<Prop> propList2 = new ArrayList<>();
|
||||
List<Prop> propList3 = new ArrayList<>();
|
||||
|
||||
List<TCComponentItemRevision> relationRevs = new ArrayList<TCComponentItemRevision>();
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
if (components[i] instanceof TCComponentItemRevision) {
|
||||
TCComponentItemRevision tcComponent = (TCComponentItemRevision) components[i];
|
||||
TCComponent[] components1 = tcComponent.getRelatedComponents("release_status_list");
|
||||
if (components1 == null || components1.length == 0) {
|
||||
MessageBox.post("存在未发布版本对象", "Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
String type = tcComponent.getType();
|
||||
System.out.println("type : "+ type);
|
||||
|
||||
boolean flag1 = false;
|
||||
for (String tempType : type1) {
|
||||
if (type.equals(tempType)) {
|
||||
flag1 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
TCComponent form = tcComponent.getRelatedComponent("IMAN_master_form_rev");
|
||||
String itemId = tcComponent.getStringProperty("item_id");
|
||||
TCComponent owningUeserRelation = tcComponent.getRelatedComponent("owning_user");
|
||||
String ownerUser = owningUeserRelation.getStringProperty("user_name");
|
||||
if (ownerUser.contains("(")) {
|
||||
ownerUser = ownerUser.substring(0, ownerUser.indexOf("("));
|
||||
}
|
||||
int cnt = 0;
|
||||
|
||||
if (flag1) {
|
||||
relationRevs.add(tcComponent);
|
||||
String[] properties = tcComponent.getProperties(prop1);
|
||||
|
||||
String property1 = form.getStringProperty("sb6_ifls");
|
||||
if(property1 != null) {
|
||||
if (property1.equals("是")) {
|
||||
property1 = "临时";
|
||||
} else if (property1.equals("否")) {
|
||||
property1 = "正式";
|
||||
} else {
|
||||
System.out.println("null");
|
||||
}
|
||||
}else {
|
||||
System.out.println("sb6_ifls属性为空");
|
||||
}
|
||||
String property2 = form.getStringProperty("sb6_relatedfileno");
|
||||
propList1.add(new Prop("", "图纸", properties[cnt++], properties[cnt++], property1,
|
||||
properties[cnt++], ownerUser, localTime, property2));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type.equals("ChangeNoticeRevision")) {
|
||||
relationRevs.add(tcComponent);
|
||||
String[] properties = form.getProperties(new String[] { "sb6_CNRM05", "sb6_CNRM05" });
|
||||
TCComponent[] tempGx = tcComponent.getRelatedComponents("CMSolutionItems");
|
||||
String itemIds = getItemId(tempGx);
|
||||
String status = getDrawingStatu(tempGx);
|
||||
|
||||
propList2.add(new Prop("", "技术文件更改通知单", properties[cnt++], properties[cnt++], itemIds, status,
|
||||
ownerUser, localTime, itemId));
|
||||
} else if (type.equals("SB6_JSWTLSCLTZDRevision")) {
|
||||
relationRevs.add(tcComponent);
|
||||
String[] properties = form.getProperties(new String[] { "sb6_LSRM05", "sb6_LSRM05" });
|
||||
TCComponent[] tempGx = tcComponent.getRelatedComponents("SB6_LSSJRelation");
|
||||
String itemIds = getItemId(tempGx);
|
||||
String status = getDrawingStatu(tempGx);
|
||||
|
||||
propList2.add(new Prop("", "临时问题处理通知单", properties[cnt++], properties[cnt++], itemIds, status,
|
||||
ownerUser, localTime, itemId));
|
||||
}
|
||||
|
||||
if (type3.equals(type)) {
|
||||
relationRevs.add(tcComponent);
|
||||
String[] properties = form.getProperties(prop3);
|
||||
|
||||
propList3.add(new Prop("", "样件试制/试生产联系单", properties[cnt++], properties[cnt++], properties[cnt++],properties[cnt++],
|
||||
ownerUser, localTime, itemId));
|
||||
}
|
||||
}
|
||||
}
|
||||
DataAllocationHandlerDialog cmbd = new DataAllocationHandlerDialog(app,propList1,propList2,propList3,relationRevs);
|
||||
new Thread(cmbd).start();
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getItemId(TCComponent[] tempGx) throws TCException {
|
||||
StringBuffer str = new StringBuffer();
|
||||
for (int i = 0; i < tempGx.length; i++) {
|
||||
TCComponent tcComponent = tempGx[i];
|
||||
str.append(tcComponent.getStringProperty("item_id"));
|
||||
if (i != tempGx.length - 1) {
|
||||
str.append("\n");
|
||||
}
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
public String getDrawingStatu(TCComponent[] tempGx) throws TCException {
|
||||
StringBuffer str = new StringBuffer();
|
||||
for (int i = 0; i < tempGx.length; i++) {
|
||||
TCComponent tcComponent = tempGx[i];
|
||||
TCComponent form = tcComponent.getRelatedComponent("IMAN_master_form_rev");
|
||||
String ifls = form.getStringProperty("sb6_ifls");
|
||||
if (ifls.equals("是")) {
|
||||
ifls = "临时" + tcComponent.getStringProperty("item_revision_id");
|
||||
} else if (ifls.equals("否")) {
|
||||
ifls = "正式" + tcComponent.getStringProperty("item_revision_id");
|
||||
} else {
|
||||
System.out.println("getDrawingStatu null");
|
||||
}
|
||||
System.out.println("ifls : " + ifls);
|
||||
str.append(ifls);
|
||||
if (i != tempGx.length - 1 || !ifls.isEmpty()) {
|
||||
str.append("\n");
|
||||
}
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.net.connor.test;
|
||||
|
||||
public class Colconfig {
|
||||
private String name;
|
||||
private String age;
|
||||
private String code;
|
||||
|
||||
public Colconfig(String name, String age, String code) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Colconfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(String age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package cn.net.connor.test;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
public class Data {
|
||||
private SimpleStringProperty name = new SimpleStringProperty();
|
||||
private SimpleStringProperty age = new SimpleStringProperty();
|
||||
private SimpleStringProperty code = new SimpleStringProperty();
|
||||
|
||||
public Data() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Data(String name, String age, String code) {
|
||||
super();
|
||||
this.name.set(name);
|
||||
this.age.set(age);
|
||||
this.code.set(code);
|
||||
}
|
||||
|
||||
public SimpleStringProperty getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(SimpleStringProperty name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public SimpleStringProperty getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(SimpleStringProperty age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public SimpleStringProperty getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(SimpleStringProperty code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package cn.net.connor.test;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.Event;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.ComboBoxTableCell;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Callback;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class Main extends Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Application.launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) {
|
||||
StackPane root = new StackPane();
|
||||
ObservableList<String> list = FXCollections.observableArrayList();
|
||||
list.add("One");
|
||||
list.add("Two");
|
||||
list.add("Three");
|
||||
list.add("Four");
|
||||
|
||||
TableColumn name = new TableColumn("Name");
|
||||
TableColumn age = new TableColumn("age");
|
||||
TableColumn code = new TableColumn("code");
|
||||
|
||||
name.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("name"));
|
||||
name.setCellFactory(ComboBoxTableCell.forTableColumn(list));
|
||||
|
||||
age.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("age"));
|
||||
age.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
code.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("code"));
|
||||
code.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
name.setOnEditCommit(new EventHandler<Event>() {
|
||||
@Override
|
||||
public void handle(Event arg0) {
|
||||
}
|
||||
});
|
||||
|
||||
ObservableList<Colconfig> datas = FXCollections.observableArrayList();
|
||||
datas.add(new Colconfig("A", "12", "1212"));
|
||||
datas.add(new Colconfig("B", "13", "1313"));
|
||||
datas.add(new Colconfig("C", "14", "1414"));
|
||||
|
||||
TableView table = new TableView(datas);
|
||||
table.setEditable(true);
|
||||
table.getColumns().addAll(name, age, code);
|
||||
|
||||
root.getChildren().add(table);
|
||||
Scene scene = new Scene(root, 300, 250);
|
||||
stage.setTitle("Test");
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cn.net.connor.test;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TitledPane;
|
||||
import javafx.scene.control.cell.ComboBoxTableCell;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class Main2 extends Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Application.launch(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) {
|
||||
VBox vBox = new VBox();
|
||||
Scene scene = new Scene(vBox, 500, 250);
|
||||
|
||||
ObservableList<String> list = FXCollections.observableArrayList();
|
||||
list.add("One");
|
||||
list.add("Two");
|
||||
list.add("Three");
|
||||
list.add("Four");
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ObservableList<Colconfig> datas = FXCollections.observableArrayList();
|
||||
datas.add(new Colconfig("A", "12", "1212"));
|
||||
datas.add(new Colconfig("B", "13", "1313"));
|
||||
datas.add(new Colconfig("C", "14", "1414"));
|
||||
|
||||
TableColumn<Colconfig, String> name = new TableColumn<>("Name");
|
||||
TableColumn<Colconfig, String> age = new TableColumn<>("Age");
|
||||
TableColumn<Colconfig, String> code = new TableColumn<>("Code");
|
||||
|
||||
name.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("name"));
|
||||
name.setCellFactory(ComboBoxTableCell.forTableColumn(list));
|
||||
|
||||
age.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("age"));
|
||||
age.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
code.setCellValueFactory(new PropertyValueFactory<Colconfig, String>("code"));
|
||||
code.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
TableView<Colconfig> table = new TableView<>(datas);
|
||||
name.setEditable(false);
|
||||
table.setEditable(true);
|
||||
table.getColumns().addAll(name, age, code);
|
||||
|
||||
TitledPane titledPane = new TitledPane("AutocadSDX" + i, table);
|
||||
titledPane.setMaxHeight(500);
|
||||
titledPane.setMinHeight(230);
|
||||
titledPane.expandedProperty().addListener((observable, wasExpanded, isExpanded) -> {
|
||||
titledPane.setMaxHeight(isExpanded ? 500 : 0);
|
||||
titledPane.setMinHeight(isExpanded ? 230 : Region.USE_PREF_SIZE);
|
||||
});
|
||||
titledPane.setAnimated(false);
|
||||
VBox.setVgrow(titledPane, Priority.ALWAYS);
|
||||
vBox.getChildren().add(titledPane);
|
||||
}
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package cn.net.connor.test;
|
||||
|
||||
public class PartBean {
|
||||
|
||||
private String id;
|
||||
private String uom;
|
||||
private String material;
|
||||
private String weight;
|
||||
|
||||
|
||||
|
||||
public PartBean() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PartBean(String id, String uom, String material, String weight) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.uom = uom;
|
||||
this.material = material;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUom() {
|
||||
return uom;
|
||||
}
|
||||
|
||||
public void setUom(String uom) {
|
||||
this.uom = uom;
|
||||
}
|
||||
|
||||
public String getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public void setMaterial(String material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public String getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(String weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package cn.net.connor.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public List<Inner> inners;
|
||||
|
||||
public Test() {
|
||||
inners = new ArrayList<Test.Inner>();
|
||||
Inner inner = new Inner(true, "A");
|
||||
Inner inner2 = new Inner(true, "A");
|
||||
;
|
||||
inners.add(inner);
|
||||
inners.add(inner2);
|
||||
System.out.println(inner);
|
||||
System.out.println(inner2);
|
||||
System.out.println(inner == inner2);
|
||||
}
|
||||
|
||||
public static class Inner {
|
||||
public boolean flag;
|
||||
public String name;
|
||||
|
||||
public Inner(boolean flag, String name) {
|
||||
super();
|
||||
this.flag = flag;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Test();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/core-renderer.jar"/>
|
||||
<classpathentry kind="lib" path="lib/iTextAsian.jar"/>
|
||||
<classpathentry kind="lib" path="lib/iTextAsianCmaps.jar"/>
|
||||
<classpathentry kind="lib" path="lib/itextpdf-5.0.6.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>cn.net.connor.pdf.lao.image</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,12 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
@ -0,0 +1,435 @@
|
||||
package com.connor.pdf;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.lowagie.text.DocumentException;
|
||||
import com.lowagie.text.Rectangle;
|
||||
import com.lowagie.text.pdf.BaseFont;
|
||||
import com.lowagie.text.pdf.PdfContentByte;
|
||||
import com.lowagie.text.pdf.PdfReader;
|
||||
import com.lowagie.text.pdf.PdfStamper;
|
||||
|
||||
public class SignPdfLao {
|
||||
public static void main(String[] args) {
|
||||
int pageCount = 1;
|
||||
SignPdfLao signPdf = new SignPdfLao();
|
||||
|
||||
String dataPath = args[0];
|
||||
String pdfPath = args[1];
|
||||
String outs = args[2];
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\老世宝PDF\\A4图纸模板.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\A4图纸模板.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\SHIBAO_A4_页_1.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\SHIBAO_A4_页_1.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\SHIBAO_SO_A4_页_1.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\SHIBAO_SO_A4_页_1.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\AA.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\AA.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\A4图纸模板.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\A4图纸模板.PDF";
|
||||
|
||||
Map<String, String> dataMap = signPdf.getData(dataPath);
|
||||
try {
|
||||
System.out.println("=====开始签字=====");
|
||||
|
||||
PdfReader reader = new PdfReader(pdfPath);
|
||||
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outs));
|
||||
Rectangle rectangle = reader.getPageSize(1);
|
||||
Float[] fposition = signPdf.getSize(rectangle);
|
||||
BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
|
||||
float x1 = 0.0F;
|
||||
float x2 = 0.0F;
|
||||
float x3 = 0.0F;
|
||||
float x4 = 0.0F;
|
||||
float y1 = 0.0F;
|
||||
float y2 = 0.0F;
|
||||
float y3 = 0.0F;
|
||||
float y4 = 0.0F;
|
||||
if (fposition[0] == 2384.0F && fposition[1] == 3370.0F) { // A0
|
||||
x1 = 2870.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 2900.0F;
|
||||
x3 = 2971.0F;
|
||||
x4 = 3003.0F;
|
||||
} else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1913.0F;
|
||||
x3 = 1985.0F;
|
||||
x4 = 2016.0F;
|
||||
} else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1214.0F;
|
||||
x3 = 1285.0F;
|
||||
x4 = 1316.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
|
||||
x1 = 703.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 735.0F;
|
||||
x3 = 805.0F;
|
||||
x4 = 837.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
|
||||
x1 = 110.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 142.0F;
|
||||
x3 = 213.0F;
|
||||
x4 = 243.0F;
|
||||
} else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
|
||||
x1 = 2870.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 2902.0F;
|
||||
x3 = 2971.0F;
|
||||
x4 = 3003.0F;
|
||||
} else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1914.0F;
|
||||
x3 = 1986.0F;
|
||||
x4 = 2017.0F;
|
||||
} else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1214.0F;
|
||||
x3 = 1285.0F;
|
||||
x4 = 1316.0F;
|
||||
} else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
|
||||
x1 = 703.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 735.0F;
|
||||
x3 = 805.0F;
|
||||
x4 = 837.0F;
|
||||
} else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
|
||||
x1 = 110.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 142.0F;
|
||||
x3 = 213.0F;
|
||||
x4 = 243.0F;
|
||||
} else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
|
||||
x1 = 4554.0F;
|
||||
y1 = 61.0F;
|
||||
y2 = 47.0F;
|
||||
y3 = 33.0F;
|
||||
y4 = 19.0F;
|
||||
x2 = 4585.5F;
|
||||
x3 = 4585.5F;
|
||||
x4 = 4585.5F;
|
||||
} else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
|
||||
x1 = 6240.0F;
|
||||
y1 = 61.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 6272.0F;
|
||||
x3 = 6272.0F;
|
||||
x4 = 6272.0F;
|
||||
} else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
|
||||
x1 = 7925.0F;
|
||||
y1 = 60.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 7957.0F;
|
||||
x3 = 7957.0F;
|
||||
x4 = 7957.0F;
|
||||
} else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
|
||||
x1 = 9614.0F;
|
||||
y1 = 60.0F;
|
||||
y2 = 46.0F;
|
||||
y3 = 32.0F;
|
||||
y4 = 18.0F;
|
||||
x2 = 9643.0F;
|
||||
x3 = 9643.0F;
|
||||
x4 = 9643.0F;
|
||||
} else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
|
||||
x1 = 11295.0F;
|
||||
y1 = 60.0F;
|
||||
y2 = 46.0F;
|
||||
y3 = 32.0F;
|
||||
y4 = 18.0F;
|
||||
x2 = 11327.0F;
|
||||
x3 = 11327.0F;
|
||||
x4 = 11327.0F;
|
||||
} else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1913.0F;
|
||||
x3 = 1985.0F;
|
||||
x4 = 2016.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1214.0F;
|
||||
x3 = 1285.0F;
|
||||
x4 = 1316.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
|
||||
x1 = 703.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 735.0F;
|
||||
x3 = 805.0F;
|
||||
x4 = 837.0F;
|
||||
} else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
|
||||
x1 = 110.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 142.0F;
|
||||
x3 = 213.0F;
|
||||
x4 = 243.0F;
|
||||
}
|
||||
|
||||
if (dataMap.containsKey("编制")) {
|
||||
String value = (String) dataMap.get("编制");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y1).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(275));
|
||||
}
|
||||
if (dataMap.containsKey("校对")) {
|
||||
String value = (String) dataMap.get("校对");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y2).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(476));
|
||||
}
|
||||
if (dataMap.containsKey("会签")) {
|
||||
String value = (String) dataMap.get("会签");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y3).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("批准")) {
|
||||
String value = (String) dataMap.get("批准");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y4).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
|
||||
if (dataMap.containsKey("编制日期")) {
|
||||
String value = (String) dataMap.get("编制日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y1).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("校对日期")) {
|
||||
String value = (String) dataMap.get("校对日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y2).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("会签日期")) {
|
||||
String value = (String) dataMap.get("会签日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y3).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("批准日期")) {
|
||||
String value = (String) dataMap.get("批准日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y4).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
|
||||
stamper.close();
|
||||
reader.close();
|
||||
System.out.println("=====签字结束=====");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getData(String filePath) {
|
||||
String lineTxt = "";
|
||||
Map<String, String> dataMap = new HashMap<>();
|
||||
try {
|
||||
String encoding = "GBK";
|
||||
File file = new File(filePath);
|
||||
if ((file.isFile()) && (file.exists())) {
|
||||
InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);
|
||||
BufferedReader bufferedReader = new BufferedReader(read);
|
||||
lineTxt = bufferedReader.readLine();
|
||||
System.out.println("linttxt=======" + lineTxt);
|
||||
|
||||
read.close();
|
||||
} else {
|
||||
System.out.println("找不到指定的文件");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("读取文件内容出错");
|
||||
e.printStackTrace();
|
||||
}
|
||||
String[] dataList = null;
|
||||
if ((lineTxt != null) && (lineTxt.length() > 0) && (lineTxt.split("\\|") != null))
|
||||
dataList = lineTxt.split("\\|");
|
||||
else {
|
||||
dataList[0] = "";
|
||||
}
|
||||
for (int i = 0; i < dataList.length; i++) {
|
||||
System.out.println("dataList=======" + dataList[i]);
|
||||
String[] datas = null;
|
||||
datas = dataList[i].split("=");
|
||||
if ((datas != null) && (datas.length > 1)) {
|
||||
dataMap.put(datas[0], datas[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public Float[] getSize(Rectangle rectangle) {
|
||||
Float[] sizef = new Float[2];
|
||||
float toleft = rectangle.getLeft();
|
||||
float tobottom = rectangle.getBottom();
|
||||
float toright = rectangle.getRight();
|
||||
float totop = rectangle.getTop();
|
||||
|
||||
JFomPdfBean bean = new JFomPdfBean();
|
||||
bean.setH(Float.valueOf(toright - toleft));
|
||||
bean.setW(Float.valueOf(totop - tobottom));
|
||||
sizef[0] = bean.getH();
|
||||
sizef[1] = bean.getW();
|
||||
System.out.println("bean.getH------------>................." + bean.getH());
|
||||
System.out.println("bean.getW------------>................." + bean.getW());
|
||||
|
||||
return sizef;
|
||||
}
|
||||
|
||||
public void signBZ(int pageCount, String value, PdfContentByte content, PdfReader reader, PdfStamper stamper,
|
||||
Integer x) {
|
||||
for (int i = 2; i <= pageCount; i++) {
|
||||
int width = x.intValue();
|
||||
SignPdfLao pdf = new SignPdfLao();
|
||||
Rectangle rectangle = reader.getPageSize(i);
|
||||
System.out.println("=========第" + i + "页=========");
|
||||
Float[] fposition = pdf.getSize(rectangle);
|
||||
try {
|
||||
BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
|
||||
String[] values = value.split(" ");
|
||||
if (values != null)
|
||||
for (int j = 0; j < values.length; j++) {
|
||||
content = stamper.getUnderContent(i);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 11.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(width).floatValue(), Float.valueOf(30.0F).floatValue());
|
||||
content.showText(values[j]);
|
||||
content.endText();
|
||||
width += 63;
|
||||
}
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,58 @@
|
||||
if (fposition[0] == 2384.0 && fposition[1] == 3370.0F) { // A0
|
||||
x1 = 3010.0F;
|
||||
y1 = 220.0F;
|
||||
} else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
|
||||
x1 = 2020.0F;
|
||||
y1 = 220.0F;
|
||||
} else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
|
||||
x1 = 1310.0F;
|
||||
y1 = 220.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
|
||||
x1 = 850.0F;
|
||||
y1 = 200.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
|
||||
x1 = 250.0F;
|
||||
y1 = 200.0F;
|
||||
}else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
|
||||
x1 = 2870.0F;
|
||||
y1 = 162.0F;
|
||||
} else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 162.0F;
|
||||
} else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 162.0F;
|
||||
} else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
|
||||
x1 = 703.0F;
|
||||
y1 = 148.0F;
|
||||
} else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
|
||||
x1 = 110.0F;
|
||||
y1 = 148.0F;
|
||||
} else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
|
||||
x1 = 4554.0F;
|
||||
y1 = 161.0F;
|
||||
} else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
|
||||
x1 = 6240.0F;
|
||||
y1 = 161.0F;
|
||||
} else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
|
||||
x1 = 7925.0F;
|
||||
y1 = 160.0F;
|
||||
} else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
|
||||
x1 = 9614.0F;
|
||||
y1 = 160.0F;
|
||||
} else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
|
||||
x1 = 11295.0F;
|
||||
y1 = 160.0F;
|
||||
}else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 210.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 210.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
|
||||
x1 = 703.0F;
|
||||
y1 = 190.0F;
|
||||
} else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
|
||||
x1 = 110.0F;
|
||||
y1 = 190.0F;
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,435 @@
|
||||
package com.connor.pdf;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.lowagie.text.DocumentException;
|
||||
import com.lowagie.text.Rectangle;
|
||||
import com.lowagie.text.pdf.BaseFont;
|
||||
import com.lowagie.text.pdf.PdfContentByte;
|
||||
import com.lowagie.text.pdf.PdfReader;
|
||||
import com.lowagie.text.pdf.PdfStamper;
|
||||
|
||||
public class SignPdfLao {
|
||||
public static void main(String[] args) {
|
||||
int pageCount = 1;
|
||||
SignPdfLao signPdf = new SignPdfLao();
|
||||
|
||||
String dataPath = args[0];
|
||||
String pdfPath = args[1];
|
||||
String outs = args[2];
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\老世宝PDF\\A4图纸模板.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\A4图纸模板.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\SHIBAO_A4_页_1.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\SHIBAO_A4_页_1.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\SHIBAO_SO_A4_页_1.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\SHIBAO_SO_A4_页_1.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\AA.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\AA.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\A4图纸模板.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\A4图纸模板.PDF";
|
||||
|
||||
Map<String, String> dataMap = signPdf.getData(dataPath);
|
||||
try {
|
||||
System.out.println("=====开始签字=====");
|
||||
|
||||
PdfReader reader = new PdfReader(pdfPath);
|
||||
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outs));
|
||||
Rectangle rectangle = reader.getPageSize(1);
|
||||
Float[] fposition = signPdf.getSize(rectangle);
|
||||
BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
|
||||
float x1 = 0.0F;
|
||||
float x2 = 0.0F;
|
||||
float x3 = 0.0F;
|
||||
float x4 = 0.0F;
|
||||
float y1 = 0.0F;
|
||||
float y2 = 0.0F;
|
||||
float y3 = 0.0F;
|
||||
float y4 = 0.0F;
|
||||
if (fposition[0] == 2384.0F && fposition[1] == 3370.0F) { // A0
|
||||
x1 = 2870.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 2900.0F;
|
||||
x3 = 2971.0F;
|
||||
x4 = 3003.0F;
|
||||
} else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1913.0F;
|
||||
x3 = 1985.0F;
|
||||
x4 = 2016.0F;
|
||||
} else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1214.0F;
|
||||
x3 = 1285.0F;
|
||||
x4 = 1316.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
|
||||
x1 = 703.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 735.0F;
|
||||
x3 = 805.0F;
|
||||
x4 = 837.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
|
||||
x1 = 110.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 142.0F;
|
||||
x3 = 213.0F;
|
||||
x4 = 243.0F;
|
||||
} else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
|
||||
x1 = 2870.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 2902.0F;
|
||||
x3 = 2971.0F;
|
||||
x4 = 3003.0F;
|
||||
} else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1914.0F;
|
||||
x3 = 1986.0F;
|
||||
x4 = 2017.0F;
|
||||
} else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1214.0F;
|
||||
x3 = 1285.0F;
|
||||
x4 = 1316.0F;
|
||||
} else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
|
||||
x1 = 703.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 735.0F;
|
||||
x3 = 805.0F;
|
||||
x4 = 837.0F;
|
||||
} else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
|
||||
x1 = 110.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 142.0F;
|
||||
x3 = 213.0F;
|
||||
x4 = 243.0F;
|
||||
} else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
|
||||
x1 = 4554.0F;
|
||||
y1 = 61.0F;
|
||||
y2 = 47.0F;
|
||||
y3 = 33.0F;
|
||||
y4 = 19.0F;
|
||||
x2 = 4585.5F;
|
||||
x3 = 4585.5F;
|
||||
x4 = 4585.5F;
|
||||
} else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
|
||||
x1 = 6240.0F;
|
||||
y1 = 61.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 6272.0F;
|
||||
x3 = 6272.0F;
|
||||
x4 = 6272.0F;
|
||||
} else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
|
||||
x1 = 7925.0F;
|
||||
y1 = 60.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 7957.0F;
|
||||
x3 = 7957.0F;
|
||||
x4 = 7957.0F;
|
||||
} else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
|
||||
x1 = 9614.0F;
|
||||
y1 = 60.0F;
|
||||
y2 = 46.0F;
|
||||
y3 = 32.0F;
|
||||
y4 = 18.0F;
|
||||
x2 = 9643.0F;
|
||||
x3 = 9643.0F;
|
||||
x4 = 9643.0F;
|
||||
} else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
|
||||
x1 = 11295.0F;
|
||||
y1 = 60.0F;
|
||||
y2 = 46.0F;
|
||||
y3 = 32.0F;
|
||||
y4 = 18.0F;
|
||||
x2 = 11327.0F;
|
||||
x3 = 11327.0F;
|
||||
x4 = 11327.0F;
|
||||
} else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1913.0F;
|
||||
x3 = 1985.0F;
|
||||
x4 = 2016.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1214.0F;
|
||||
x3 = 1285.0F;
|
||||
x4 = 1316.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
|
||||
x1 = 703.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 735.0F;
|
||||
x3 = 805.0F;
|
||||
x4 = 837.0F;
|
||||
} else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
|
||||
x1 = 110.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 142.0F;
|
||||
x3 = 213.0F;
|
||||
x4 = 243.0F;
|
||||
}
|
||||
|
||||
if (dataMap.containsKey("编制")) {
|
||||
String value = (String) dataMap.get("编制");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y1).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(275));
|
||||
}
|
||||
if (dataMap.containsKey("校对")) {
|
||||
String value = (String) dataMap.get("校对");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y2).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(476));
|
||||
}
|
||||
if (dataMap.containsKey("会签")) {
|
||||
String value = (String) dataMap.get("会签");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y3).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("批准")) {
|
||||
String value = (String) dataMap.get("批准");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y4).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
|
||||
if (dataMap.containsKey("编制日期")) {
|
||||
String value = (String) dataMap.get("编制日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y1).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("校对日期")) {
|
||||
String value = (String) dataMap.get("校对日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y2).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("会签日期")) {
|
||||
String value = (String) dataMap.get("会签日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y3).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("批准日期")) {
|
||||
String value = (String) dataMap.get("批准日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y4).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
|
||||
stamper.close();
|
||||
reader.close();
|
||||
System.out.println("=====签字结束=====");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getData(String filePath) {
|
||||
String lineTxt = "";
|
||||
Map<String, String> dataMap = new HashMap<>();
|
||||
try {
|
||||
String encoding = "GBK";
|
||||
File file = new File(filePath);
|
||||
if ((file.isFile()) && (file.exists())) {
|
||||
InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);
|
||||
BufferedReader bufferedReader = new BufferedReader(read);
|
||||
lineTxt = bufferedReader.readLine();
|
||||
System.out.println("linttxt=======" + lineTxt);
|
||||
|
||||
read.close();
|
||||
} else {
|
||||
System.out.println("找不到指定的文件");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("读取文件内容出错");
|
||||
e.printStackTrace();
|
||||
}
|
||||
String[] dataList = null;
|
||||
if ((lineTxt != null) && (lineTxt.length() > 0) && (lineTxt.split("\\|") != null))
|
||||
dataList = lineTxt.split("\\|");
|
||||
else {
|
||||
dataList[0] = "";
|
||||
}
|
||||
for (int i = 0; i < dataList.length; i++) {
|
||||
System.out.println("dataList=======" + dataList[i]);
|
||||
String[] datas = null;
|
||||
datas = dataList[i].split("=");
|
||||
if ((datas != null) && (datas.length > 1)) {
|
||||
dataMap.put(datas[0], datas[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public Float[] getSize(Rectangle rectangle) {
|
||||
Float[] sizef = new Float[2];
|
||||
float toleft = rectangle.getLeft();
|
||||
float tobottom = rectangle.getBottom();
|
||||
float toright = rectangle.getRight();
|
||||
float totop = rectangle.getTop();
|
||||
|
||||
JFomPdfBean bean = new JFomPdfBean();
|
||||
bean.setH(Float.valueOf(toright - toleft));
|
||||
bean.setW(Float.valueOf(totop - tobottom));
|
||||
sizef[0] = bean.getH();
|
||||
sizef[1] = bean.getW();
|
||||
System.out.println("bean.getH------------>................." + bean.getH());
|
||||
System.out.println("bean.getW------------>................." + bean.getW());
|
||||
|
||||
return sizef;
|
||||
}
|
||||
|
||||
public void signBZ(int pageCount, String value, PdfContentByte content, PdfReader reader, PdfStamper stamper,
|
||||
Integer x) {
|
||||
for (int i = 2; i <= pageCount; i++) {
|
||||
int width = x.intValue();
|
||||
SignPdfLao pdf = new SignPdfLao();
|
||||
Rectangle rectangle = reader.getPageSize(i);
|
||||
System.out.println("=========第" + i + "页=========");
|
||||
Float[] fposition = pdf.getSize(rectangle);
|
||||
try {
|
||||
BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
|
||||
String[] values = value.split(" ");
|
||||
if (values != null)
|
||||
for (int j = 0; j < values.length; j++) {
|
||||
content = stamper.getUnderContent(i);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 11.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(width).floatValue(), Float.valueOf(30.0F).floatValue());
|
||||
content.showText(values[j]);
|
||||
content.endText();
|
||||
width += 63;
|
||||
}
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
if (fposition[0] == 2384.0 && fposition[1] == 3370.0F) { // A0
|
||||
x1 = 3010.0F;
|
||||
y1 = 220.0F;
|
||||
} else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
|
||||
x1 = 2020.0F;
|
||||
y1 = 220.0F;
|
||||
} else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
|
||||
x1 = 1310.0F;
|
||||
y1 = 220.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
|
||||
x1 = 850.0F;
|
||||
y1 = 200.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
|
||||
x1 = 250.0F;
|
||||
y1 = 200.0F;
|
||||
}else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
|
||||
x1 = 2870.0F;
|
||||
y1 = 162.0F;
|
||||
} else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 162.0F;
|
||||
} else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 162.0F;
|
||||
} else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
|
||||
x1 = 703.0F;
|
||||
y1 = 148.0F;
|
||||
} else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
|
||||
x1 = 110.0F;
|
||||
y1 = 148.0F;
|
||||
} else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
|
||||
x1 = 4554.0F;
|
||||
y1 = 161.0F;
|
||||
} else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
|
||||
x1 = 6240.0F;
|
||||
y1 = 161.0F;
|
||||
} else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
|
||||
x1 = 7925.0F;
|
||||
y1 = 160.0F;
|
||||
} else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
|
||||
x1 = 9614.0F;
|
||||
y1 = 160.0F;
|
||||
} else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
|
||||
x1 = 11295.0F;
|
||||
y1 = 160.0F;
|
||||
}else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 210.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 210.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
|
||||
x1 = 703.0F;
|
||||
y1 = 190.0F;
|
||||
} else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
|
||||
x1 = 110.0F;
|
||||
y1 = 190.0F;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="llib/core-renderer.jar"/>
|
||||
<classpathentry kind="lib" path="llib/iTextAsian.jar"/>
|
||||
<classpathentry kind="lib" path="llib/iTextAsianCmaps.jar"/>
|
||||
<classpathentry kind="lib" path="llib/itextpdf-5.0.6.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>cn.net.connor.pdf.xin.image</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,12 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/core-renderer.jar"/>
|
||||
<classpathentry kind="lib" path="lib/itext-2.0.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/iText-5.0.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/iTextAsian.jar"/>
|
||||
<classpathentry kind="lib" path="lib/iTextAsianCmaps.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.connor.pdf</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,41 @@
|
||||
package com.connor.pdf;
|
||||
|
||||
public class JFomPdfBean {
|
||||
private Float w = 0.0f;
|
||||
private Float h = 0.0f;
|
||||
private Float wi = 0.0f;
|
||||
private Float hi = 0.0f;
|
||||
|
||||
public Float getW() {
|
||||
return w;
|
||||
}
|
||||
|
||||
public void setW(Float w) {
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public Float getH() {
|
||||
return h;
|
||||
}
|
||||
|
||||
public void setH(Float h) {
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
public Float getWi() {
|
||||
return wi;
|
||||
}
|
||||
|
||||
public void setWi(Float wi) {
|
||||
this.wi = wi;
|
||||
}
|
||||
|
||||
public Float getHi() {
|
||||
return hi;
|
||||
}
|
||||
|
||||
public void setHi(Float hi) {
|
||||
this.hi = hi;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,431 @@
|
||||
package com.connor.pdf;
|
||||
|
||||
import com.lowagie.text.DocumentException;
|
||||
import com.lowagie.text.Rectangle;
|
||||
import com.lowagie.text.pdf.BaseFont;
|
||||
import com.lowagie.text.pdf.PdfContentByte;
|
||||
import com.lowagie.text.pdf.PdfReader;
|
||||
import com.lowagie.text.pdf.PdfStamper;
|
||||
import java.awt.Color;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SignPdfXin {
|
||||
public static void main(String[] args) {
|
||||
int pageCount = 1;
|
||||
SignPdfXin signPdf = new SignPdfXin();
|
||||
|
||||
String dataPath = args[0];
|
||||
String pdfPath = args[1];
|
||||
String outs = args[2];
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\新世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\新世宝PDF\\A4-SHUBANG.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\新世宝CAD输出\\A4-SHUBANG.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\新世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\新世宝CAD\\1.5A0.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\新世宝CAD输出\\1.5A0.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\新世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\新世宝CAD\\A4-SHUBANG.PDF";//A0-HENGBAN A4-SHUBANG
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\新世宝CAD输出\\A4-SHUBANG.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\新世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\新建文件夹 (4)\\新世宝\\A4HENG.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\新世宝CAD输出\\A4HENG.PDF";
|
||||
|
||||
Map<String, String> dataMap = signPdf.getData(dataPath);
|
||||
try {
|
||||
PdfReader reader = new PdfReader(pdfPath);
|
||||
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outs));
|
||||
Rectangle rectangle = reader.getPageSize(1);
|
||||
Float[] fposition = signPdf.getSize(rectangle);
|
||||
BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
|
||||
float x1 = 0.0F;
|
||||
float x2 = 0.0F;
|
||||
float x3 = 0.0F;
|
||||
float x4 = 0.0F;
|
||||
float y1 = 0.0F;
|
||||
float y2 = 0.0F;
|
||||
float y3 = 0.0F;
|
||||
float y4 = 0.0F;
|
||||
if (fposition[0] == 2384.0F && fposition[1] == 3370.0F) {// A0-HENGBAN
|
||||
x1 = 2834.0F;
|
||||
y1 = 110.0F;
|
||||
y2 = 90.0F;
|
||||
y3 = 70.0F;
|
||||
y4 = 52.0F;
|
||||
x2 = 2871.0F;
|
||||
x3 = 2950.0F;
|
||||
x4 = 2980.0F;
|
||||
System.out.println("aaaaa");
|
||||
} else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) {// A1-HENGBAN
|
||||
x1 = 1837.0F;
|
||||
y1 = 110.0F;
|
||||
y2 = 90.0F;
|
||||
y3 = 70.0F;
|
||||
y4 = 50.0F;
|
||||
x2 = 1870.0F;
|
||||
x3 = 1950.0F;
|
||||
x4 = 1985.0F;
|
||||
} else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) {// A2-HENGBAN
|
||||
x1 = 1176.0F;
|
||||
y1 = 83.0F;
|
||||
y2 = 62.0F;
|
||||
y3 = 43.0F;
|
||||
y4 = 23.0F;
|
||||
x2 = 1210.0F;
|
||||
x3 = 1288.0F;
|
||||
x4 = 1324.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) {// A3-HENGBAN
|
||||
x1 = 686.0F;
|
||||
y1 = 82.0F;
|
||||
y2 = 60.0F;
|
||||
y3 = 40.0F;
|
||||
y4 = 21.0F;
|
||||
x2 = 719.0F;
|
||||
x3 = 800.0F;
|
||||
x4 = 833.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 595.0F) {// A4-HENGBAN
|
||||
x1 = 338.0F;
|
||||
y1 = 80.0F;
|
||||
y2 = 61.0F;
|
||||
y3 = 42.0F;
|
||||
y4 = 24.0F;
|
||||
x2 = 370.0F;
|
||||
x3 = 450.0F;
|
||||
x4 = 483.0F;
|
||||
} else if (fposition[0] == 595.0F && fposition[1] == 842.0F) {// A4-SHUBANG
|
||||
x1 = 93.0F;
|
||||
y1 = 80.0F;
|
||||
y2 = 61.0F;
|
||||
y3 = 42.0F;
|
||||
y4 = 24.0F;
|
||||
x2 = 127.0F;
|
||||
x3 = 205.0F;
|
||||
x4 = 238.0F;
|
||||
} else if (fposition[0] == 2384.0F && fposition[1] == 5056.0F) {// 1.5A0
|
||||
x1 = 4520.0F;
|
||||
y1 = 108.0F;
|
||||
y2 = 90.0F;
|
||||
y3 = 70.0F;
|
||||
y4 = 52.0F;
|
||||
x2 = 4555.0F;
|
||||
x3 = 4635.0F;
|
||||
x4 = 4670.0F;
|
||||
}else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) {//A0
|
||||
x1 = 2837.0F;
|
||||
y1 = 110.0F;
|
||||
y2 = 90.0F;
|
||||
y3 = 70.0F;
|
||||
y4 = 50.0F;
|
||||
x2 = 2870.0F;
|
||||
x3 = 2950.0F;
|
||||
x4 = 2985.0F;
|
||||
} else if (fposition[0] == 5055.6F && fposition[1] == 2383.94F) {//A01.5
|
||||
x1 = 4520.0F;
|
||||
y1 = 110.0F;
|
||||
y2 = 90.0F;
|
||||
y3 = 70.0F;
|
||||
y4 = 50.0F;
|
||||
x2 = 4555.0F;
|
||||
x3 = 4635.0F;
|
||||
x4 = 4670.0F;
|
||||
} else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) {// A1
|
||||
x1 = 1848.0F;
|
||||
y1 = 110.0F;
|
||||
y2 = 90.0F;
|
||||
y3 = 70.0F;
|
||||
y4 = 50.0F;
|
||||
x2 = 1883.0F;
|
||||
x3 = 1963.0F;
|
||||
x4 = 1998.0F;
|
||||
} else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) {// A2
|
||||
x1 = 1178.0F;
|
||||
y1 = 83.0F;
|
||||
y2 = 62.0F;
|
||||
y3 = 43.0F;
|
||||
y4 = 23.0F;
|
||||
x2 = 1212.0F;
|
||||
x3 = 1290.0F;
|
||||
x4 = 1326.0F;
|
||||
} else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) {// A3
|
||||
x1 = 686.0F;
|
||||
y1 = 82.0F;
|
||||
y2 = 60.0F;
|
||||
y3 = 40.0F;
|
||||
y4 = 21.0F;
|
||||
x2 = 719.0F;
|
||||
x3 = 800.0F;
|
||||
x4 = 833.0F;
|
||||
} else if (fposition[0] == 595.28F && fposition[1] == 841.89F) {// A4
|
||||
x1 = 91.0F;
|
||||
y1 = 80.0F;
|
||||
y2 = 61.0F;
|
||||
y3 = 42.0F;
|
||||
y4 = 24.0F;
|
||||
x2 = 125.0F;
|
||||
x3 = 203.0F;
|
||||
x4 = 236.0F;
|
||||
} else if (fposition[0] == 841.89F && fposition[1] == 595.28F) {// A4HEN
|
||||
x1 = 338.0F;
|
||||
y1 = 80.0F;
|
||||
y2 = 61.0F;
|
||||
y3 = 42.0F;
|
||||
y4 = 24.0F;
|
||||
x2 = 370.0F;
|
||||
x3 = 450.0F;
|
||||
x4 = 483.0F;
|
||||
}
|
||||
|
||||
|
||||
if (dataMap.containsKey("设计")) {
|
||||
String value = dataMap.get("设计");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y1).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(275));
|
||||
}
|
||||
if (dataMap.containsKey("校对")) {
|
||||
String value = dataMap.get("校对");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y2).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(476));
|
||||
}
|
||||
if (dataMap.containsKey("审核")) {
|
||||
String value = dataMap.get("审核");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y3).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("工艺")) {
|
||||
String value = dataMap.get("工艺");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y4).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("标准化")) {
|
||||
String value = dataMap.get("标准化");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x3).floatValue(), Float.valueOf(y1).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("会签")) {
|
||||
String value = dataMap.get("会签");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x3).floatValue(), Float.valueOf(y3).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("批准")) {
|
||||
String value = dataMap.get("批准");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x3).floatValue(), Float.valueOf(y4).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("设计日期")) {
|
||||
String value = dataMap.get("设计日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 7.5F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y1).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("校对日期")) {
|
||||
String value = dataMap.get("校对日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 7.5F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y2).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("审核日期")) {
|
||||
String value = dataMap.get("审核日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 7.5F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y3).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("工艺日期")) {
|
||||
String value = dataMap.get("工艺日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 7.5F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y4).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("标准化日期")) {
|
||||
String value = dataMap.get("标准化日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 7.5F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x4).floatValue(), Float.valueOf(y1).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("会签日期")) {
|
||||
String value = dataMap.get("会签日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 7.5F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x4).floatValue(), Float.valueOf(y3).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("批准日期")) {
|
||||
String value = dataMap.get("批准日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 7.5F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x4).floatValue(), Float.valueOf(y4).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
stamper.close();
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getData(String filePath) {
|
||||
String lineTxt = "";
|
||||
Map<Object, Object> dataMap = new HashMap<Object, Object>();
|
||||
try {
|
||||
String encoding = "GBK";
|
||||
File file = new File(filePath);
|
||||
if (file.isFile() && file.exists()) {
|
||||
InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);
|
||||
BufferedReader bufferedReader = new BufferedReader(read);
|
||||
lineTxt = bufferedReader.readLine();
|
||||
System.out.println("linttxt=======" + lineTxt);
|
||||
read.close();
|
||||
} else {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String[] dataList = null;
|
||||
if (lineTxt != null && lineTxt.length() > 0 && lineTxt.split("\\|") != null) {
|
||||
dataList = lineTxt.split("\\|");
|
||||
} else {
|
||||
dataList[0] = "";
|
||||
}
|
||||
for (int i = 0; i < dataList.length; i++) {
|
||||
System.out.println("dataList=======" + dataList[i]);
|
||||
String[] datas = null;
|
||||
datas = dataList[i].split("=");
|
||||
if (datas != null && datas.length > 1)
|
||||
dataMap.put(datas[0], datas[1]);
|
||||
}
|
||||
return (Map) dataMap;
|
||||
}
|
||||
|
||||
public Float[] getSize(Rectangle rectangle) {
|
||||
Float[] sizef = new Float[2];
|
||||
float toleft = rectangle.getLeft();
|
||||
float tobottom = rectangle.getBottom();
|
||||
float toright = rectangle.getRight();
|
||||
float totop = rectangle.getTop();
|
||||
JFomPdfBean bean = new JFomPdfBean();
|
||||
bean.setH(Float.valueOf(toright - toleft));
|
||||
bean.setW(Float.valueOf(totop - tobottom));
|
||||
sizef[0] = bean.getH();
|
||||
sizef[1] = bean.getW();
|
||||
System.out.println("bean.getH------------>................." + bean.getH());
|
||||
System.out.println("bean.getW------------>................." + bean.getW());
|
||||
return sizef;
|
||||
}
|
||||
|
||||
public void signBZ(int pageCount, String value, PdfContentByte content, PdfReader reader, PdfStamper stamper,
|
||||
Integer x) {
|
||||
for (int i = 2; i <= pageCount; i++) {
|
||||
int width = x.intValue();
|
||||
SignPdfXin pdf = new SignPdfXin();
|
||||
Rectangle rectangle = reader.getPageSize(i);
|
||||
System.out.println("=========+ i + ");
|
||||
Float[] fposition = pdf.getSize(rectangle);
|
||||
try {
|
||||
BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
|
||||
String[] values = value.split(" ");
|
||||
if (values != null)
|
||||
for (int j = 0; j < values.length; j++) {
|
||||
content = stamper.getUnderContent(i);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 11.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(width).floatValue(), Float.valueOf(30.0F).floatValue());
|
||||
content.showText(values[j]);
|
||||
content.endText();
|
||||
width += 63;
|
||||
}
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/core-renderer.jar"/>
|
||||
<classpathentry kind="lib" path="lib/itext-2.0.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/iText-5.0.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/iTextAsian.jar"/>
|
||||
<classpathentry kind="lib" path="lib/iTextAsianCmaps.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.connor.pdfLao</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,41 @@
|
||||
package com.connor.pdf;
|
||||
|
||||
public class JFomPdfBean {
|
||||
private Float w = 0.0f;
|
||||
private Float h = 0.0f;
|
||||
private Float wi = 0.0f;
|
||||
private Float hi = 0.0f;
|
||||
|
||||
public Float getW() {
|
||||
return w;
|
||||
}
|
||||
|
||||
public void setW(Float w) {
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public Float getH() {
|
||||
return h;
|
||||
}
|
||||
|
||||
public void setH(Float h) {
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
public Float getWi() {
|
||||
return wi;
|
||||
}
|
||||
|
||||
public void setWi(Float wi) {
|
||||
this.wi = wi;
|
||||
}
|
||||
|
||||
public Float getHi() {
|
||||
return hi;
|
||||
}
|
||||
|
||||
public void setHi(Float hi) {
|
||||
this.hi = hi;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,435 @@
|
||||
package com.connor.pdf;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.lowagie.text.DocumentException;
|
||||
import com.lowagie.text.Rectangle;
|
||||
import com.lowagie.text.pdf.BaseFont;
|
||||
import com.lowagie.text.pdf.PdfContentByte;
|
||||
import com.lowagie.text.pdf.PdfReader;
|
||||
import com.lowagie.text.pdf.PdfStamper;
|
||||
|
||||
public class SignPdfLao {
|
||||
public static void main(String[] args) {
|
||||
int pageCount = 1;
|
||||
SignPdfLao signPdf = new SignPdfLao();
|
||||
|
||||
String dataPath = args[0];
|
||||
String pdfPath = args[1];
|
||||
String outs = args[2];
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\老世宝PDF\\A4图纸模板.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\A4图纸模板.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\SHIBAO_A4_页_1.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\SHIBAO_A4_页_1.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\SHIBAO_SO_A4_页_1.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\SHIBAO_SO_A4_页_1.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\AA.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\AA.PDF";
|
||||
|
||||
// String dataPath = "C:\\Users\\infodba\\Desktop\\老世宝签字.txt";
|
||||
// String pdfPath = "C:\\Users\\infodba\\Desktop\\TC模板CATIAPDF\\A4图纸模板.PDF";
|
||||
// String outs = "C:\\Users\\infodba\\Desktop\\老世宝CAD输出\\A4图纸模板.PDF";
|
||||
|
||||
Map<String, String> dataMap = signPdf.getData(dataPath);
|
||||
try {
|
||||
System.out.println("=====开始签字=====");
|
||||
|
||||
PdfReader reader = new PdfReader(pdfPath);
|
||||
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outs));
|
||||
Rectangle rectangle = reader.getPageSize(1);
|
||||
Float[] fposition = signPdf.getSize(rectangle);
|
||||
BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
|
||||
float x1 = 0.0F;
|
||||
float x2 = 0.0F;
|
||||
float x3 = 0.0F;
|
||||
float x4 = 0.0F;
|
||||
float y1 = 0.0F;
|
||||
float y2 = 0.0F;
|
||||
float y3 = 0.0F;
|
||||
float y4 = 0.0F;
|
||||
if (fposition[0] == 2384.0F && fposition[1] == 3370.0F) { // A0
|
||||
x1 = 2870.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 2900.0F;
|
||||
x3 = 2971.0F;
|
||||
x4 = 3003.0F;
|
||||
} else if (fposition[0] == 2384.0F && fposition[1] == 1684.0F) { // A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1913.0F;
|
||||
x3 = 1985.0F;
|
||||
x4 = 2016.0F;
|
||||
} else if (fposition[0] == 1684.0F && fposition[1] == 1191.0F) { // A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1214.0F;
|
||||
x3 = 1285.0F;
|
||||
x4 = 1316.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 842.0F) { // A3
|
||||
x1 = 703.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 735.0F;
|
||||
x3 = 805.0F;
|
||||
x4 = 837.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 595.0F) { // A4
|
||||
x1 = 110.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 142.0F;
|
||||
x3 = 213.0F;
|
||||
x4 = 243.0F;
|
||||
} else if (fposition[0] == 3370.4F && fposition[1] == 2383.94F) { // CATIA A0
|
||||
x1 = 2870.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 2902.0F;
|
||||
x3 = 2971.0F;
|
||||
x4 = 3003.0F;
|
||||
} else if (fposition[0] == 2383.94F && fposition[1] == 1683.78F) { // CATIA A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1914.0F;
|
||||
x3 = 1986.0F;
|
||||
x4 = 2017.0F;
|
||||
} else if (fposition[0] == 1683.78F && fposition[1] == 1190.56F) { // CATIA A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1214.0F;
|
||||
x3 = 1285.0F;
|
||||
x4 = 1316.0F;
|
||||
} else if (fposition[0] == 1190.56F && fposition[1] == 841.89F) { // CATIA A3
|
||||
x1 = 703.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 735.0F;
|
||||
x3 = 805.0F;
|
||||
x4 = 837.0F;
|
||||
} else if (fposition[0] == 595.28F && fposition[1] == 841.89F) { // CATIA A4
|
||||
x1 = 110.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 142.0F;
|
||||
x3 = 213.0F;
|
||||
x4 = 243.0F;
|
||||
} else if (fposition[0] == 5054.18F && fposition[1] == 2383.94F) { // CATIA S0 A0
|
||||
x1 = 4554.0F;
|
||||
y1 = 61.0F;
|
||||
y2 = 47.0F;
|
||||
y3 = 33.0F;
|
||||
y4 = 19.0F;
|
||||
x2 = 4585.5F;
|
||||
x3 = 4585.5F;
|
||||
x4 = 4585.5F;
|
||||
} else if (fposition[0] == 6740.79F && fposition[1] == 2383.94F) { // CATIA S0 A1
|
||||
x1 = 6240.0F;
|
||||
y1 = 61.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 6272.0F;
|
||||
x3 = 6272.0F;
|
||||
x4 = 6272.0F;
|
||||
} else if (fposition[0] == 8424.57F && fposition[1] == 2383.94F) { // CATIA S0 A2
|
||||
x1 = 7925.0F;
|
||||
y1 = 60.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 7957.0F;
|
||||
x3 = 7957.0F;
|
||||
x4 = 7957.0F;
|
||||
} else if (fposition[0] == 10111.19F && fposition[1] == 2383.94F) { // CATIA S0 A3
|
||||
x1 = 9614.0F;
|
||||
y1 = 60.0F;
|
||||
y2 = 46.0F;
|
||||
y3 = 32.0F;
|
||||
y4 = 18.0F;
|
||||
x2 = 9643.0F;
|
||||
x3 = 9643.0F;
|
||||
x4 = 9643.0F;
|
||||
} else if (fposition[0] == 11794.97F && fposition[1] == 2383.94F) { // CATIA S0 A4
|
||||
x1 = 11295.0F;
|
||||
y1 = 60.0F;
|
||||
y2 = 46.0F;
|
||||
y3 = 32.0F;
|
||||
y4 = 18.0F;
|
||||
x2 = 11327.0F;
|
||||
x3 = 11327.0F;
|
||||
x4 = 11327.0F;
|
||||
} else if (fposition[0] == 1684.0F && fposition[1] == 2384.0F) { // A1
|
||||
x1 = 1885.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1913.0F;
|
||||
x3 = 1985.0F;
|
||||
x4 = 2016.0F;
|
||||
} else if (fposition[0] == 1191.0F && fposition[1] == 1684.0F) { // A2
|
||||
x1 = 1183.0F;
|
||||
y1 = 62.0F;
|
||||
y2 = 48.0F;
|
||||
y3 = 34.0F;
|
||||
y4 = 20.0F;
|
||||
x2 = 1214.0F;
|
||||
x3 = 1285.0F;
|
||||
x4 = 1316.0F;
|
||||
} else if (fposition[0] == 842.0F && fposition[1] == 1191.0F) { // A3
|
||||
x1 = 703.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 735.0F;
|
||||
x3 = 805.0F;
|
||||
x4 = 837.0F;
|
||||
} else if (fposition[0] == 595.0F && fposition[1] == 842.0F) { // A4
|
||||
x1 = 110.0F;
|
||||
y1 = 48.0F;
|
||||
y2 = 34.0F;
|
||||
y3 = 20.0F;
|
||||
y4 = 6.0F;
|
||||
x2 = 142.0F;
|
||||
x3 = 213.0F;
|
||||
x4 = 243.0F;
|
||||
}
|
||||
|
||||
if (dataMap.containsKey("编制")) {
|
||||
String value = (String) dataMap.get("编制");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y1).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(275));
|
||||
}
|
||||
if (dataMap.containsKey("校对")) {
|
||||
String value = (String) dataMap.get("校对");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y2).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
// signPdf.signBZ(pageCount, value, content, reader, stamper, Integer.valueOf(476));
|
||||
}
|
||||
if (dataMap.containsKey("会签")) {
|
||||
String value = (String) dataMap.get("会签");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y3).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("批准")) {
|
||||
String value = (String) dataMap.get("批准");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 9.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x1).floatValue(), Float.valueOf(y4).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
|
||||
if (dataMap.containsKey("编制日期")) {
|
||||
String value = (String) dataMap.get("编制日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y1).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("校对日期")) {
|
||||
String value = (String) dataMap.get("校对日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y2).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("会签日期")) {
|
||||
String value = (String) dataMap.get("会签日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y3).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
if (dataMap.containsKey("批准日期")) {
|
||||
String value = (String) dataMap.get("批准日期");
|
||||
PdfContentByte content = stamper.getUnderContent(1);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 6.2F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(x2).floatValue(), Float.valueOf(y4).floatValue());
|
||||
content.showText(value);
|
||||
content.endText();
|
||||
}
|
||||
|
||||
stamper.close();
|
||||
reader.close();
|
||||
System.out.println("=====签字结束=====");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getData(String filePath) {
|
||||
String lineTxt = "";
|
||||
Map<String, String> dataMap = new HashMap<>();
|
||||
try {
|
||||
String encoding = "GBK";
|
||||
File file = new File(filePath);
|
||||
if ((file.isFile()) && (file.exists())) {
|
||||
InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);
|
||||
BufferedReader bufferedReader = new BufferedReader(read);
|
||||
lineTxt = bufferedReader.readLine();
|
||||
System.out.println("linttxt=======" + lineTxt);
|
||||
|
||||
read.close();
|
||||
} else {
|
||||
System.out.println("找不到指定的文件");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("读取文件内容出错");
|
||||
e.printStackTrace();
|
||||
}
|
||||
String[] dataList = null;
|
||||
if ((lineTxt != null) && (lineTxt.length() > 0) && (lineTxt.split("\\|") != null))
|
||||
dataList = lineTxt.split("\\|");
|
||||
else {
|
||||
dataList[0] = "";
|
||||
}
|
||||
for (int i = 0; i < dataList.length; i++) {
|
||||
System.out.println("dataList=======" + dataList[i]);
|
||||
String[] datas = null;
|
||||
datas = dataList[i].split("=");
|
||||
if ((datas != null) && (datas.length > 1)) {
|
||||
dataMap.put(datas[0], datas[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public Float[] getSize(Rectangle rectangle) {
|
||||
Float[] sizef = new Float[2];
|
||||
float toleft = rectangle.getLeft();
|
||||
float tobottom = rectangle.getBottom();
|
||||
float toright = rectangle.getRight();
|
||||
float totop = rectangle.getTop();
|
||||
|
||||
JFomPdfBean bean = new JFomPdfBean();
|
||||
bean.setH(Float.valueOf(toright - toleft));
|
||||
bean.setW(Float.valueOf(totop - tobottom));
|
||||
sizef[0] = bean.getH();
|
||||
sizef[1] = bean.getW();
|
||||
System.out.println("bean.getH------------>................." + bean.getH());
|
||||
System.out.println("bean.getW------------>................." + bean.getW());
|
||||
|
||||
return sizef;
|
||||
}
|
||||
|
||||
public void signBZ(int pageCount, String value, PdfContentByte content, PdfReader reader, PdfStamper stamper,
|
||||
Integer x) {
|
||||
for (int i = 2; i <= pageCount; i++) {
|
||||
int width = x.intValue();
|
||||
SignPdfLao pdf = new SignPdfLao();
|
||||
Rectangle rectangle = reader.getPageSize(i);
|
||||
System.out.println("=========第" + i + "页=========");
|
||||
Float[] fposition = pdf.getSize(rectangle);
|
||||
try {
|
||||
BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
|
||||
String[] values = value.split(" ");
|
||||
if (values != null)
|
||||
for (int j = 0; j < values.length; j++) {
|
||||
content = stamper.getUnderContent(i);
|
||||
content.beginText();
|
||||
content.setColorFill(Color.BLACK);
|
||||
content.setFontAndSize(base, 11.0F);
|
||||
content.setTextRise(14.0F);
|
||||
content.setTextMatrix(Float.valueOf(width).floatValue(), Float.valueOf(30.0F).floatValue());
|
||||
content.showText(values[j]);
|
||||
content.endText();
|
||||
width += 63;
|
||||
}
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/k.util_1.0.0.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.connor.wj.plm</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
@ -0,0 +1,23 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Plm
|
||||
Bundle-SymbolicName: com.connor.wj.plm;singleton:=true
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: com.connor.wj.plm.Activator
|
||||
Bundle-Vendor: CONNOR
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
com.teamcenter.rac.aifrcp;bundle-version="12000.1.0",
|
||||
com.teamcenter.rac.ui;bundle-version="12000.1.0",
|
||||
com.teamcenter.rac.kernel;bundle-version="12000.1.0",
|
||||
com.teamcenter.rac.ui.commands;bundle-version="12000.1.0",
|
||||
com.teamcenter.rac.util;bundle-version="12000.1.0",
|
||||
com.teamcenter.rac.external;bundle-version="12000.1.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Automatic-Module-Name: com.connor.wj.plm
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.connor.wj.plm,
|
||||
com.connor.wj.plm.dialogs,
|
||||
com.connor.wj.plm.handlers
|
||||
Bundle-ClassPath: .,
|
||||
lib/k.util_1.0.0.jar
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue