mirror of
https://github.com/arias007/obsidian-mobile-pdf-exporter.git
synced 2026-07-22 07:45:20 +00:00
Publish v0.3.2 packaged plugin
This commit is contained in:
commit
50c91c1460
9 changed files with 409 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
node_modules/
|
||||
.DS_Store
|
||||
*.log
|
||||
*.tmp
|
||||
*.map
|
||||
dist/
|
||||
*.pdf
|
||||
*.zip
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2026 Murat / Codex
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
76
README.md
Normal file
76
README.md
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# Obsidian Mobile PDF Exporter
|
||||
|
||||
One-click preview-style PDF export for Obsidian mobile and desktop.
|
||||
|
||||
This repository currently publishes the packaged `v0.3.2` build that was validated in a real Obsidian vault. It is intended for manual installation or release-asset downloads.
|
||||
|
||||
## Features
|
||||
|
||||
- Adds a ribbon button, command palette command, and note menu item: `导出预览版 PDF`.
|
||||
- Exports the current Markdown note through an Obsidian preview-rendered layout.
|
||||
- Uses a phone-width PDF page size for mobile-style reading.
|
||||
- Keeps exported text selectable and copyable by writing real PDF text.
|
||||
- Embeds images separately.
|
||||
- Draws lightweight block backgrounds for code blocks, tables, quotes, and callouts.
|
||||
- Bundles `NotoSansSC-Regular.otf` for offline Chinese text export.
|
||||
|
||||
## Install
|
||||
|
||||
Download `mobile-pdf-exporter-v0.3.2.zip` from the GitHub release, then extract it into:
|
||||
|
||||
```text
|
||||
<your-vault>/.obsidian/plugins/mobile-pdf-exporter/
|
||||
```
|
||||
|
||||
The plugin folder should contain:
|
||||
|
||||
```text
|
||||
manifest.json
|
||||
main.js
|
||||
styles.css
|
||||
versions.json
|
||||
fonts/NotoSansSC-Regular.otf
|
||||
```
|
||||
|
||||
Restart Obsidian, or disable and re-enable the plugin from Obsidian settings.
|
||||
|
||||
## Usage
|
||||
|
||||
Open a Markdown note, then click the `导出预览版 PDF` ribbon/menu command. The exported PDF is saved to `PDF Exports` in the current vault by default.
|
||||
|
||||
## Notes
|
||||
|
||||
Markor can create selectable preview PDFs through Android WebView printing. Obsidian plugins do not expose the same Android native print pipeline, so this plugin uses a browser-side approach: render the Obsidian preview layout, collect visible text/image positions, then write a real selectable PDF.
|
||||
|
||||
The original local build tried `fonts/SimHei.ttf` first and then fell back to `fonts/NotoSansSC-Regular.otf`. This public repository intentionally does not redistribute `SimHei.ttf`; the included Noto Sans SC font is used as the public fallback.
|
||||
|
||||
## Changelog
|
||||
|
||||
### 0.3.2
|
||||
|
||||
- Replaced the full-page snapshot background with visible vector PDF text to avoid blurry exports.
|
||||
- Fixed page-width calculation so wide DOM content is wrapped inside the phone-size PDF instead of being clipped.
|
||||
- Tightened export CSS for tables, code blocks, long links, and embeds to reduce side overflow.
|
||||
- Uses actual content bottom for pagination to avoid trailing blank pages.
|
||||
- Adds image embedding and lightweight block backgrounds without rasterizing the whole page.
|
||||
|
||||
### 0.3.1
|
||||
|
||||
- Fixed PDF font initialization when the bundled fontkit export shape is `{ default: fontkit }`.
|
||||
- Removed Obsidian-specific DOM helper calls from the renderer setup for better mobile compatibility.
|
||||
- Kept the preview-first approach: render preview layout, then write a real selectable PDF text layer.
|
||||
|
||||
### 0.3.0
|
||||
|
||||
- Removed Text/Snapshot mode selection.
|
||||
- Removed the options export command.
|
||||
- Added one-click preview PDF export from ribbon, command palette, and note menu.
|
||||
- Writes selectable text from the preview DOM, not from a plain Markdown text dump.
|
||||
- Uses a preview snapshot only as the visual background; text remains real PDF text.
|
||||
- Falls back to visible selectable text if snapshot capture fails, avoiding blank PDFs.
|
||||
|
||||
## License
|
||||
|
||||
Plugin code and packaged JavaScript are released under the MIT License.
|
||||
|
||||
Bundled Noto Sans SC font is licensed under the SIL Open Font License 1.1. See `fonts/LICENSE-OFL.txt`.
|
||||
89
fonts/LICENSE-OFL.txt
Normal file
89
fonts/LICENSE-OFL.txt
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
SIL OPEN FONT LICENSE
|
||||
|
||||
Version 1.1 - 26 February 2007
|
||||
|
||||
PREAMBLE
|
||||
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The fonts,
|
||||
including any derivative works, can be bundled, embedded, redistributed
|
||||
and/or sold with any software provided that any reserved names are not used
|
||||
by derivative works. The fonts and derivatives, however, cannot be released
|
||||
under any other type of license. The requirement for fonts to remain under
|
||||
this license does not apply to any document created using the fonts or their
|
||||
derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may include
|
||||
source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting, or
|
||||
substituting, in part or in whole, any of the components of the Original
|
||||
Version, by changing formats or by porting the Font Software to a new
|
||||
environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical writer or
|
||||
other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION AND CONDITIONS
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font Software,
|
||||
subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components, in
|
||||
Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be included
|
||||
either as stand-alone text files, human-readable headers or in the
|
||||
appropriate machine-readable metadata fields within text or binary files as
|
||||
long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any Modified
|
||||
Version, except to acknowledge the contribution(s) of the Copyright
|
||||
Holder(s) and the Author(s) or with their explicit written permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole, must be
|
||||
distributed entirely under this license, and must not be distributed under
|
||||
any other license. The requirement for fonts to remain under this license
|
||||
does not apply to any document created using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
|
||||
This license becomes null and void if any of the above conditions are not
|
||||
met.
|
||||
|
||||
DISCLAIMER
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS
|
||||
IN THE FONT SOFTWARE.
|
||||
BIN
fonts/NotoSansSC-Regular.otf
Normal file
BIN
fonts/NotoSansSC-Regular.otf
Normal file
Binary file not shown.
104
main.js
Normal file
104
main.js
Normal file
File diff suppressed because one or more lines are too long
9
manifest.json
Normal file
9
manifest.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"id": "mobile-pdf-exporter",
|
||||
"name": "Mobile PDF Exporter",
|
||||
"version": "0.3.2",
|
||||
"minAppVersion": "1.5.0",
|
||||
"description": "One-click selectable preview PDF export for Obsidian mobile and desktop.",
|
||||
"author": "Murat / Codex",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
94
styles.css
Normal file
94
styles.css
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
.mobile-pdf-exporter-render-root {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 2147483647;
|
||||
display: block;
|
||||
width: var(--mobile-pdf-exporter-width, 794px);
|
||||
min-height: 1px;
|
||||
max-height: none;
|
||||
overflow: visible;
|
||||
opacity: 1;
|
||||
pointer-events: none;
|
||||
visibility: visible;
|
||||
background: var(--background-primary);
|
||||
color: var(--text-normal);
|
||||
print-color-adjust: exact;
|
||||
-webkit-print-color-adjust: exact;
|
||||
}
|
||||
|
||||
.mobile-pdf-exporter-page {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: var(--mobile-pdf-exporter-padding, 40px);
|
||||
background: var(--background-primary);
|
||||
color: var(--text-normal);
|
||||
overflow: hidden;
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-word;
|
||||
font-size: var(--font-text-size);
|
||||
line-height: var(--line-height-normal);
|
||||
}
|
||||
|
||||
.mobile-pdf-exporter-page .markdown-preview-view {
|
||||
padding: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.mobile-pdf-exporter-page *,
|
||||
.mobile-pdf-exporter-page *::before,
|
||||
.mobile-pdf-exporter-page *::after {
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.mobile-pdf-exporter-title {
|
||||
margin: 0 0 1em;
|
||||
font-size: 1.8em;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.mobile-pdf-exporter-page img,
|
||||
.mobile-pdf-exporter-page svg,
|
||||
.mobile-pdf-exporter-page canvas,
|
||||
.mobile-pdf-exporter-page video {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.mobile-pdf-exporter-page table {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
overflow-wrap: anywhere;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.mobile-pdf-exporter-page pre {
|
||||
white-space: pre-wrap;
|
||||
overflow-x: hidden;
|
||||
overflow-wrap: anywhere;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.mobile-pdf-exporter-page code,
|
||||
.mobile-pdf-exporter-page a,
|
||||
.mobile-pdf-exporter-page td,
|
||||
.mobile-pdf-exporter-page th {
|
||||
overflow-wrap: anywhere;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.mobile-pdf-exporter-page .markdown-embed,
|
||||
.mobile-pdf-exporter-page .internal-embed,
|
||||
.mobile-pdf-exporter-page .markdown-preview-sizer {
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.mobile-pdf-exporter-page .markdown-source-view,
|
||||
.mobile-pdf-exporter-page .cm-editor {
|
||||
display: none;
|
||||
}
|
||||
8
versions.json
Normal file
8
versions.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"0.1.0": "1.5.0",
|
||||
"0.1.1": "1.5.0",
|
||||
"0.2.0": "1.5.0",
|
||||
"0.3.0": "1.5.0",
|
||||
"0.3.1": "1.5.0",
|
||||
"0.3.2": "1.5.0"
|
||||
}
|
||||
Loading…
Reference in a new issue