Small PDF
Small PDF is a Portable Document Format sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.
small.pdfDocument
ページ記述を中心とした文書形式。通常は先頭付近の%PDF-からバージョン宣言が始まります。
25 50 44 46 2D %PDF-SIGNATURE = bytes.fromhex("255044462d")
OFFSET = 0
def is_pdf(path: str) -> bool:
with open(path, "rb") as f:
f.seek(OFFSET)
head = f.read(len(SIGNATURE))
return head == SIGNATUREconst SIGNATURE = [0x25, 0x50, 0x44, 0x46, 0x2d];
const OFFSET = 0;
// bytes: a Uint8Array / Buffer holding the start of the file
export function isPdf(bytes) {
return SIGNATURE.every((byte, i) => bytes[OFFSET + i] === byte);
}package fileid
import "bytes"
var ispdfSignature = []byte{0x25, 0x50, 0x44, 0x46, 0x2d}
const ispdfOffset = 0
func IsPdf(b []byte) bool {
end := ispdfOffset + len(ispdfSignature)
if len(b) < end {
return false
}
return bytes.Equal(b[ispdfOffset:end], ispdfSignature)
}const SIGNATURE: &[u8] = &[0x25, 0x50, 0x44, 0x46, 0x2d];
const OFFSET: usize = 0;
fn is_pdf(bytes: &[u8]) -> bool {
bytes.get(OFFSET..OFFSET + SIGNATURE.len()) == Some(SIGNATURE)
}<?php
$signature = "\x25\x50\x44\x46\x2d";
$offset = 0;
function is_pdf(string $bytes): bool {
global $signature, $offset;
return substr($bytes, $offset, strlen($signature)) === $signature;
}Portable Document Format はデータ交換、インポート/エクスポート、パーサのテスト、検証ワークフローで使われます。エンコーディング・区切り文字・バージョン・コンテナ構造が実装の挙動を変えることがあります。
文書形式はスクリプト・添付・マクロ・外部参照を含むことがあります。プレビューや変換はサンドボックス化し、信頼できないファイルを直接開かないでください。
11 個のサンプルで、先頭バイト判定・パーサのエラー・アップロード上限・ダウンロード挙動をテストできます。
Small PDF is a Portable Document Format sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.
small.pdfPDF with Metadata is a Portable Document Format sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.
note-with-metadata.pdfBlue Sky PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
01-blue-sky.pdfe4c697ed1efd7fc82f69d9b69461ff3d0a10ac86fab771fa9734dd6227fe58ddFlower Garden PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
02-flower-garden.pdf7d924c973b66969ea3c4fb2fc53c1bbb3ff04ce03999bc28215295aa9616c156Navy Blue Sky PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
03-navy-blue-sky.pdff4cd44f622ebdb47b094f20f038863d6ecd8e092d3e283f4b989ea579e357ebdNature of the Sky PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
04-nature-sky.pdf454a460c2673d8e93f7158c851c1af39b9adfd585663bac7d59a3d24a4205e51Sky Landscape PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
05-sky-landscape.pdf4b1fa5611d64d91b474b2373ad44df768be2e3b7a4e61bc48571fe0e1d3615e0Starry Sky PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
06-starry-sky.pdf54cf9824543461bb44d900b3dd35e263a14130365e7dd32264b8319f41e7d7adBlue Night Sky PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
07-blue-night-sky.pdf8bddc3e2dbfcea5f81616ead2af7e08d7b9c4de91f72a2facb3756b5898f2226Hibiscus Flower PDF is a Portable Document Format sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
08-hibiscus-flower.pdf6ed98d6bd8b56da3977af81b40a9f3b73b64e2fc568934488f1b3a4e6f577b81NASA Blue Marble PDF is a Portable Document Format sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.
nasa-blue-marble-2012-east.pdff3368791d86a5b759647de15e92b666d9f137152aceaf457ab461304f2d9c27cPortable Document Format ファイルはバイトシグネチャ 25 50 44 46 2D ("%PDF-") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。
Portable Document Format のMIMEタイプは application/pdf です。
Portable Document Format ファイルは .pdf 拡張子を使います。拡張子は慣習にすぎず中身を保証しないため、シグネチャや構造のチェックと組み合わせてください。