File size: 4,906 Bytes
99b5353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157

<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>PDF Simulator | Static Space Pro</title>
    <link rel="stylesheet" href="style.css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" />
<style>
        .pdf-page {
            position: relative;
            width: 800px;
            height: 1100px;
            margin: 20px auto;
            background-color: white;
            box-shadow: 0 0 10px rgba(0,0,0,0.2);
            overflow: hidden;
        }
        .editable-box {
            position: absolute;
            border: 1px solid rgba(200,200,200,0.8);
            box-shadow: 0 0 5px rgba(200,200,255,0.5);
            min-width: 100px;
            min-height: 50px;
            resize: none;
            overflow: hidden;
            background-color: rgba(255,255,255,0.9);
            cursor: move;
            padding: 5px;
        }
.editable-box:focus {
            outline: none;
            border: 1px solid rgba(0,100,255,0.5);
        }
.add-box-btn {
            position: fixed;
            bottom: 20px;
            right: 20px;
            padding: 10px 20px;
            background: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
.delete-box-btn {
            position: absolute;
            top: 5px;
            right: 5px;
            background: rgba(0,0,0,0.3);
            color: white;
            border: none;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            cursor: pointer;
            font-size: 12px;
            display: none;
        }
        .editable-box:hover .delete-box-btn {
            display: block;
        }
</style>
</head>
<body>
  <header>
    <div class="logo">
      <i class="fas fa-file-pdf"></i>
      <span>PDF Simulator</span>
    </div>
    <nav>
      <a href="index.html" class="btn"><i class="fas fa-home"></i> Home</a>
    </nav>
  </header>

  <main>
    <div class="card">
      <h1>PDF Simulator</h1>
      <p>Click anywhere on the page to add editable text boxes or use the Add button.</p>
      <p>Drag to move, resize with handles, and delete when needed.</p>
    </div>
    <div class="pdf-page" id="pdfPage"></div>
    <button class="btn" id="addBoxBtn" style="position: fixed; bottom: 20px; right: 20px;">
      <i class="fas fa-plus"></i> Add Text Box
    </button>
  </main>
  
  <script>
document.getElementById('addBoxBtn').addEventListener('click', addEditableBox);
        document.getElementById('pdfPage').addEventListener('click', function(e) {
            if (e.target === this) {
                addEditableBox(e.clientX - this.offsetLeft, e.clientY - this.offsetTop);
            }
        });

        function addEditableBox(x = 50, y = 50) {
            const box = document.createElement('div');
            box.className = 'editable-box';
            box.contentEditable = true;
            box.style.left = x + 'px';
            box.style.top = y + 'px';
const deleteBtn = document.createElement('button');
            deleteBtn.className = 'delete-box-btn';
            deleteBtn.innerHTML = '×';
            deleteBtn.addEventListener('click', function(e) {
                e.stopPropagation();
                box.remove();
            });

            box.appendChild(deleteBtn);
document.getElementById('pdfPage').appendChild(box);
            box.focus();

            // Make draggable
            makeDraggable(box);
        }

        function makeDraggable(element) {
            let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
            
            element.onmousedown = dragMouseDown;

            function dragMouseDown(e) {
                if (e.target.className.includes('add-line-btn') || 
                    e.target.className.includes('delete-box-btn')) return;
                    
                e = e || window.event;
                e.preventDefault();
                pos3 = e.clientX;
                pos4 = e.clientY;
                document.onmouseup = closeDragElement;
                document.onmousemove = elementDrag;
            }

            function elementDrag(e) {
                e = e || window.event;
                e.preventDefault();
                pos1 = pos3 - e.clientX;
                pos2 = pos4 - e.clientY;
                pos3 = e.clientX;
                pos4 = e.clientY;
                element.style.top = (element.offsetTop - pos2) + "px";
                element.style.left = (element.offsetLeft - pos1) + "px";
            }

            function closeDragElement() {
                document.onmouseup = null;
                document.onmousemove = null;
            }
        }
    </script>
  </script>
</body>
</html>