Use javascript to make Submission PDF compliant with main PDF eCTD Specifications
- a
- Aug 26, 2023
- 3 min read
This includes some of the following checks plus many more
PDF Version: It checks if the PDF version is higher than 1.7.
Metadata: It ensures that the PDF has the essential metadata:
Title
Author
Subject
Keywords
Security: Verifies if the PDF is encrypted or password-protected.
Page Size & Orientation: Ensures every page is A4 size and checks its orientation.
Embedded Fonts: Checks if all fonts used in the PDF are embedded within it.
Bookmarks & Bookmark Panel Status:
If bookmarks are present, the bookmarks panel should be open.
If bookmarks are absent, the bookmarks panel should be closed.
Document Size: Checks if the document size exceeds a specified limit (in this script, 100MB).
Thumbnails: Ensures thumbnails are present.
Non-standard Annotations: Warns about any annotations found that aren't Text, Link, or FreeText types.
Rotation: Verifies if any page has been rotated from its original position.
Hyperlinks: Checks for the presence of external hyperlinks, especially those leading to the web (http: or https: links).
Note: This list is derived from the script you provided earlier. It offers a broad overview, but it's worth noting that, depending on the specific eCTD guidelines and regional differences, additional checks might be necessary.
var msg = "";
// 1. PDF Version
var pdfVersion = this.info.PDFFormatVersion;
if (parseFloat(pdfVersion) > 1.7) {
msg += "Warning: PDF version is higher than 1.7.\n";
}
// 2. Metadata
var title = this.info.Title;
var author = this.info.Author;
var subject = this.info.Subject;
var keywords = this.info.Keywords;
if (!title || !author || !subject || !keywords) {
msg += "Warning: PDF lacks essential metadata (title, author, subject, or keywords).\n";
}
// 3. Security
if (this.securityHandler) {
msg += "Warning: PDF is encrypted or password protected.\n";
}
// 4. Page Size & Orientation
for (var j = 0; j < this.numPages; j++) {
var pg = this.getPageBox("Crop", j);
var width = pg[2] - pg[0];
var height = pg[1] - pg[3];
if ((width !== 595 || height !== 842) && (width !== 842 || height !== 595)) {
msg += "Warning: Page " + (j+1) + " is not A4 size or not in the right orientation.\n";
}
}
// 5. Embedded Fonts
var fontInfo = this.getFonts();
var allFontsEmbedded = true;
for (var i = 0; i < fontInfo.length; i++) {
if (!fontInfo[i].embedded) {
allFontsEmbedded = false;
break;
}
}
if (!allFontsEmbedded) {
msg += "Warning: Not all fonts are embedded.\n";
}
// 6. Bookmarks & Bookmark Panel Status
if (this.bookmarkRoot.children) {
if (app.execMenuItem("ShowHideBookmarks") == false) {
msg += "Warning: PDF has bookmarks but bookmark panel is closed.\n";
}
} else {
if (app.execMenuItem("ShowHideBookmarks") == true) {
msg += "Warning: PDF lacks bookmarks but bookmark panel is open.\n";
}
}
// 7. Document Size
var fileSize = this.dataObjects[0].size;
if (fileSize > 100 * 1024 * 1024) { // assuming 100MB as the limit
msg += "Warning: File size exceeds the acceptable limit.\n";
}
// 8. Thumbnails
if (!this.getPageNumWords(0)) {
msg += "Warning: Thumbnails may not be present.\n";
}
// 9. Non-standard annotations
for (var n = 0; n < this.numPages; n++) {
var allAnnots = this.getAnnots({ nPage: n });
if (allAnnots) {
for (var an = 0; an < allAnnots.length; an++) {
if (["Text", "Link", "FreeText"].indexOf(allAnnots[an].type) == -1) {
msg += "Warning: Non-standard annotation found on page " + (n+1) + ".\n";
}
}
}
}
// 10. Rotation
for (var x = 0; x < this.numPages; x++) {
var rotation = this.getPageRotation({nPage: x});
if (rotation !== 0) {
msg += "Warning: Page " + (x+1) + " has been rotated.\n";
}
}
// 11. Hyperlinks
// As per eCTD guidelines, documents should not have external hyperlinks
for (var m = 0; m < this.numPages; m++) {
var linkAnnots = this.getAnnots({ nPage: m, cName: "Link" });
if (linkAnnots) {
for (var ln = 0; ln < linkAnnots.length; ln++) {
if (linkAnnots[ln].url && (linkAnnots[ln].url.indexOf("http:") >= 0 || linkAnnots[ln].url.indexOf("https:") >= 0)) {
msg += "Warning: PDF contains external hyperlinks on page " + (m+1) + ".\n";
}
}
}
}
// Output Results
if (msg) {
app.alert(msg, 3);
} else {
app.alert("PDF passed all checks. Ensure any other specific eCTD requirements are also met.", 3);
}
Comments