-
Notifications
You must be signed in to change notification settings - Fork 5
feat: HTML-to-PDF layout options and watermark positioning #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jdrhyne
wants to merge
2
commits into
main
Choose a base branch
from
feat/html-layout-watermark-positioning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,6 +168,48 @@ export const AiRedactArgsSchema = z.object({ | |
| ), | ||
| }) | ||
|
|
||
| export const PageSizePresetSchema = z.enum([ | ||
| 'A0', | ||
| 'A1', | ||
| 'A2', | ||
| 'A3', | ||
| 'A4', | ||
| 'A5', | ||
| 'A6', | ||
| 'A7', | ||
| 'A8', | ||
| 'Letter', | ||
| 'Legal', | ||
| ]) | ||
|
|
||
| export const HTMLLayoutSchema = z | ||
| .object({ | ||
| orientation: z | ||
| .enum(['landscape', 'portrait']) | ||
| .optional() | ||
| .describe('Page orientation for HTML-to-PDF conversion.'), | ||
| size: z | ||
| .union([ | ||
| PageSizePresetSchema, | ||
| z.object({ | ||
| width: z.number().positive().describe('Page width in millimeters.'), | ||
| height: z.number().positive().describe('Page height in millimeters.'), | ||
| }), | ||
| ]) | ||
| .optional() | ||
| .describe('Page size as a preset name (e.g. "A4", "Letter") or custom dimensions in millimeters.'), | ||
| margin: z | ||
| .object({ | ||
| left: z.number().min(0).describe('Left margin in millimeters.'), | ||
| top: z.number().min(0).describe('Top margin in millimeters.'), | ||
| right: z.number().min(0).describe('Right margin in millimeters.'), | ||
| bottom: z.number().min(0).describe('Bottom margin in millimeters.'), | ||
| }) | ||
| .optional() | ||
| .describe('Page margins in millimeters.'), | ||
| }) | ||
| .optional() | ||
|
|
||
| export const FilePartSchema = z.object({ | ||
| file: z | ||
| .string() | ||
|
|
@@ -180,6 +222,10 @@ export const FilePartSchema = z.object({ | |
| .string() | ||
| .optional() | ||
| .describe("Used to determine the file type when the file content type is not available and can't be inferred."), | ||
| layout: HTMLLayoutSchema.optional().describe( | ||
| 'Page layout options for HTML-to-PDF conversion. Only applies when the input is an HTML file. ' + | ||
| 'Supports orientation, page size, and margins.', | ||
| ), | ||
|
|
||
| // For simplicity, we do not allow actions to be performed on individual parts. Instead, actions can be performed on the resulting parts output. | ||
| // actions: z | ||
|
|
@@ -254,20 +300,16 @@ export const BaseWatermarkPropertiesSchema = z.object({ | |
| .describe( | ||
| 'For image watermarks, the path to the image file or a reference to a file in the multipart request. Resolves to sandbox path if enabled, otherwise resolves to the local file system.', | ||
| ), | ||
|
|
||
| // For simplicity, we apply the watermark to the center of the page. | ||
| // top: WatermarkDimensionSchema.optional().describe('Offset of the watermark from the top edge of a page.'), | ||
| // right: WatermarkDimensionSchema.optional().describe('Offset of the watermark from the right edge of a page.'), | ||
| // bottom: WatermarkDimensionSchema.optional().describe('Offset of the watermark from the bottom edge of a page.'), | ||
| // left: WatermarkDimensionSchema.optional().describe('Offset of the watermark from the left edge of a page.'), | ||
|
|
||
| // For simplicity, we do not support custom fonts. | ||
| // fontFamily: z.string().optional().describe('The font to render the text.'), | ||
| // fontSize: z.number().optional().describe('Size of the text in points.'), | ||
| // fontStyle: z | ||
| // .array(z.enum(['bold', 'italic'])) | ||
| // .optional() | ||
| // .describe('Text style. Can be only italic, only bold, italic and bold, or none of these.'), | ||
| top: WatermarkDimensionSchema.optional().describe('Offset of the watermark from the top edge of a page.'), | ||
| right: WatermarkDimensionSchema.optional().describe('Offset of the watermark from the right edge of a page.'), | ||
| bottom: WatermarkDimensionSchema.optional().describe('Offset of the watermark from the bottom edge of a page.'), | ||
| left: WatermarkDimensionSchema.optional().describe('Offset of the watermark from the left edge of a page.'), | ||
| fontFamily: z.string().optional().describe('The font family to use for text watermarks.'), | ||
| fontSize: z.number().positive().optional().describe('Font size in points for text watermarks.'), | ||
| fontStyle: z | ||
| .array(z.enum(['bold', 'italic'])) | ||
| .optional() | ||
| .describe('Font style for text watermarks. Can be italic, bold, or both.'), | ||
|
Comment on lines
+303
to
+312
|
||
| }) | ||
|
|
||
| export const SearchPresetSchema = z.enum([ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: We can remove this
optional. It's up to the consumer to decide if the schema is optional, i.e.FilePartSchema.